ソフトウェアテスト01

T1、T2及びT3を構築しながら、このようなことは:単純なプログラムP(F1及びF2 2つの障害を含む)として構成

  1. T1は別々に行われ、F1の故障に見出さ。
  2. T2は別々に行われ、F2に障害を発見しました。
  3. T3は同時にF1とF2に行われ、F1のエラー、ない失敗を生成することができます。//詳細なメモを記入してください

/*
 * @Descripttion:
 *  Fault:静态存在软件中的缺陷,coding中的出错,写错了
    Error:运行过程中触发的中间状态
    Failure:Error传不到软件外面,测试人员能看到
 * @version:
 * @Author: edisonhuang
 * @Date: 2020-03-01 12:40:00
 * @LastEditors: edisonhuang
 * @LastEditTime: 2020-03-01 14:30:07
 */




public class Test {
    public static void P(int [] numbers){
        int lenth = numbers.length;
        double mean,sum;
        sum = 0.0;

        if (lenth > 2  )
        {
            // 计算数组所有元素的平均值
            for (int i = 1; i < lenth; i++) {   // Fault1 i应该为0
                sum += numbers[i];
            }
            // 在程序中传递出去
            mean = sum / (double) lenth;
            System.out.println("Mean:" + mean);
        }
        if (lenth <= 4 )
        {
           // 计算数组内最大值
            int max = numbers[0];
            for (int i = 1; i < lenth; i++) {
                if (numbers[i] < max)       // Fault2 应为 numbers[i] > max
                {
                    max = numbers[i];
                }
            }
            System.out.println("Max:" + max );
        }


    }

    public static void main(String[] args) {
        int t1[] = {2, 3, 5, 6, 9}; // 构造t1
        int t2[] = {5, 6};  // 构造t2
        int t3[] = {0, 5, 4};   // 构造t3
        System.out.print("t1期待输出:Mean:5,实际输出:");
        P(t1);
        System.out.println("----------------------------------");
        System.out.print("t2期待输出:Max:6,实际输出:");
        P(t2);
        System.out.println("----------------------------------");
        System.out.print("t3期待输出:\n" + "Mean:3.0" + "\n" + "Max:5\n" + "实际输出:\n");
        P(t3);
        System.out.println("----------------------------------");
    }

}

公開された35元の記事 ウォンの賞賛1 ビュー1850

おすすめ

転載: blog.csdn.net/qq_40672635/article/details/104594160