software_testing_work3_question2

时间:2022-07-18 19:46:34
 package com.Phantom;

 import java.rmi.server.Operation;
import java.util.Scanner; public class Work3_2 { /**
* @param args
*/
float x;
float y;
String step1;
String step2;
String step3; public void setX(float x) {
this.x = x;
} public void setY(float y) {
this.y = y;
} public Work3_2() {
} public int operation(){
step1="a";
if(x<4||y>0){
step2="b";
if(y>1){
step3="c";
y=y+1;
}
else{
step3="d";
}
}
else{
step2="e";
if(x>=5){
step3="f";
x=x-y;
}
else{
step3="g";
x=x+y;
}
}
System.out.println("输出X >>>"+x);
System.out.println("输出Y >>>"+y);
System.out.println("路径:");
System.out.println(step1+"——>"+step2+"——>"+step3);
return 0;
} }

测试类

 package com.Phantom;

 import static org.junit.Assert.*;

 import org.junit.After;
import org.junit.Before;
import org.junit.Test; public class Work3_2_teting {
private Work3_2 w1;
@Before
public void setUp() throws Exception {
w1=new Work3_2();
} @After
public void tearDown() throws Exception {
} @Test
public void test() {
/*
* a-e-g
* */
w1.setX(4);
w1.setY(0);
w1.operation();
System.out.println("-----------------");
/*
* a-e-f
* */
w1.setX(5);
w1.setY(0);
w1.operation();
System.out.println("-----------------");
/*
* a-b-d_(1)
* */
w1.setX(4);
w1.setY((float) 0.1);
w1.operation();
System.out.println("-----------------");
/*
* a-b-d_(2)
* */
w1.setX(3);
w1.setY(-1);
w1.operation();
System.out.println("-----------------");
/*
* a-b-c
* */
w1.setX(4);
w1.setY(2);
w1.operation();
System.out.println("-----------------"); } }

运行junit测试

software_testing_work3_question2

software_testing_work3_question2

software_testing_work3_question2