测试用例:
|
语句覆盖:
1. x=3,y=3,z=0. 预期输出 x=2 (a(T),b(T))
2. x=3,y=3,z=1. 预期输出 x=1 (a(F),b(T))
判定覆盖:
1. x=3,y=1,z=0. 预期输出 x=2 (a(F),b(F))
2. x=3,y=3,z=0. 预期输出 x=2 (a(T),b(T))
条件覆盖:
1. x=1,y=1,z=1. 预期输出 x=0 (a(F,F),b(F,F))
2. x=3,y=3,z=0. 预期输出 x=2 (a(T,T),b(T,T))
判定条件覆盖:
1. x=1,y=1,z=1. 预期输出 x=0 (a(F,F),b(F,F))
2. x=3,y=3,z=0. 预期输出 x=2 (a(T,T),b(T,T))
条件组合覆盖:
1. x=3,y=3,z=0. 预期输出 x=2 (a(T),b(T))
2. x=3,y=1,z=0. 预期输出 x=2 (a(F),b(F))
3. x=3,y=4,z=0. 预期输出 x=-1 (a(T),b(F))
4. x=3,y=3,z=1. 预期输出 x=1 (a(F),b(T))
|
代码:
1 import java.util.Scanner;
2
3
4 public class MyText {
5 private static Scanner cin = null;
6 static{
7 cin = new Scanner(System.in);
8 }
9 public static void main(String[] args) {
10 int x, y, z;
11 while(cin.hasNext()){
12
13 System.out.println();
14 System.out.println("请输入x,y,z的值!");
15 x = cin.nextInt();
16 y = cin.nextInt();
17 z = cin.nextInt();
18
19 System.out.printf("您输入的 x = %d, y = %d, z = %d\n", x, y, z);
20 if(y > 2 && z == 0){
21 x = x / y;
22 }else{
23 x = x - y;
24 }
25 if(y == 3 || x > 1){
26 x = x + 1;
27 }else{
28
29 }
30 System.out.println("x 的值为: " + x);
31 }
32 }
33 }
2.基路径法设计测试
某航空公司在顾客购买机票的时候分以下几种情况出售机票:普通顾客在机票销售淡季购买机票享受7折优惠,在机票销售旺季购买机票全价(不打折);普通会员顾客在机票销售淡季购买机票享受5折优惠,在机票销售旺季购买机票8折;金卡会员顾客在机票销售淡季购买机票享受3折优惠,在机票销售旺季购买机票6折。
航空公司各售票点使用售票软件进行售票管理。请使用基路径测试法设计测试用例以测试售票软件的以上功能。
实验要求
①根据航空售票功能描述,画出相应的程序流程图;
②使用基路径法设计测试用例;
③根据航空售票功能描述,编写实现此功能的程序;
④根据测试用例对程序实施手工测试;
⑤撰写实验报告。
程序流程图:


