Software Test Third Job 2

Source: Internet
Author: User

2. Application of Logic overlay

• Write Java code (implemented using classes and methods) in accordance with the program flowchart given

Write a test case that is overwritten by a statement, a branch overlay, and the path it covers, and test with JUnit to write test cases

Package HAN;

import Java.util.Scanner;

/**

*

* @author Hanzhenyi

* 2016.4.7

* 2, the application of logic coverage

*/

Public class a {

Public Static void Main (string[] args) {

Scanner in = new Scanner (System. in);

System. out. println ("Please enter the first number x:");

int x = In.nextint ();

System. out. println ("Please enter a second number y:");

int y = in.nextint ();

if (X<4 | | y>0) {

if (y>1) {

y=y+1;

}

}

Else {

if (x>=5) {

X=x-y;

}

Else {

X=x+y;

}

}

System. out. println ("The value of the output X is:" +x+ ", the value of the output Y is:" +y+ ");

}

Public void Demo (int i, int j) {

TODO auto-generated Method stub

}

}

Statement overrides:

Path

Test Case X

Test Case Y

Aeg

3

0

Aef

6

0

Abc

5

3

Branch Overrides

Path

Test Case X

Test Case Y

Aeg

3

0

Aef

6

0

Abc

5

3

Abd

5

1

Package HAN;

Import static org.junit.assert.*;

Import Org.junit.Before;

Import Org.junit.Test;

public class Twotest {

@Before

public void SetUp () throws Exception {

}

@Test

public void Test () {

Both demo =new ();

Demo.demo (3,0);

Demo.demo (6,0);

Demo.demo (5,3);

Demo.demo (5,1);

}

Software Test Third Job 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.