ST work12——failure,fault,error

Below are four faulty programs. Each includes a test case that results in failure. Answer the following questions (in the next slide) about each program.

 Identify the fault.

   第一个程序是循环遍历没有遍历到x[0]

   第二个程序要求找到最后一个0,但该程序只是找到了第一个0

 If possible, identify a test case that does not execute the fault. (Reachability)

  第一个程序的测试样例

  test :x = [] y = 0;

  第二个程序的测试样例:

  Test :x=[] y= 0;

 If possible, identify a test case that executes the fault, but does not result in an error state.

  第一个程序测试样例:

  x=[2,3,5];y=1

  第二个程序的测试样例:

  X=[2,3,5];y=1

 If possible identify a test case that results in an error, but not a failure.

  第一个程序测试样例:

  test: x=[2, 3, 5]; y = 2

  第二个测试程序样例:

  test: x=[0, 1, 0]; y=0

原文地址:https://www.cnblogs.com/CsharpNote/p/5263874.html