PIE模型

PIE模型:

  • Fault、Error & Failure:

Software Fault:A static defect in the software

Software  Error:An incorrect internal state that is the manifestation of some faults

Software  Failure:External,incorrect behavior with respect to the requirements or other description of the expected behavior

Fault:静态存在于软件当中的缺陷,coding当中的错误

Error:运行中运行到Fault触发到了错误的中间状态

Failure:失效,Error传播到软件外面,可被用户或测试人员观察到

 

  • 具体示例:
        public static void CSta(int[] numbers) {
		int length = numbers.length;
		double mean,sum;
		
		sum = 0.0;
		for (int i = 1; i < length; i++) {//i = 0
			sum += numbers[i];
		}
		mean = sum / (double)length;
		
		System.out.println("mean:"+mean);
	}

Fault:

for (int i = 1; i < length; i++) {//i = 0

Test Input[3,4,5]

Error:

        sum = 3+4+5

        sum = 4+5

Failure:

        sum = 3+4+5

        sum = 4+5

        mean = 4

        mean = 3

 

  • PIE Model:

Execution/Reachability:The location or locations in the program that contain the fault must be reached

Infection:The state of the program must be incorrect

Propagation:The infected state must propagate to cause some output of the program to be incorrect

PIE模型前提:

执行必须通过了错误代码

执行代码时必须触发错误的中间状态

错误的中间状态被传播输出

 

  • 注意:

很多时候测试未必能执行到fault的位置

测试执行到错误代码,却不一定触发Error

有Error不一定有Failure

Is there is a fault,which cnnot be revealed by any test?

Is it a fault or not fault?

有没有一个Fault,可能产生Error,但最终的输出都是一致的?

这样的Fault是Fault吗?

 

Fault反思:

Fault,Error不易判定;Failure易判定

  • 通过修复操作定义Fault:
        //通过修复操作定义Fault
	int max1(int x, int y) {
		int max = x;
		if(x>y) { // --> if(x<y)
			max = y;
			return max;
		}
		return max;
	}
	//不同的修复定义了不同的Fault
	int max2(int x, int y) {
		int max = x;// --> int max = y;
		if(x>y) { 
			max = y;// --> max = x;
			return max;
		}
		return max;
	}
  • 通过测试定义:
        //一个错误的修复示范:
	int max3(int x, int y) {
		int max = x;
		if(x>y) { 
			max = y;// --> max = x;
			return max;
		}
		return max;
	}

Input 3,5 :测试失败

Input 5,3:测试通过

相同的修复+不同的测试     也可能使测试人员断定Fault与否的结果完全不一样

        int max4(int x, int y) {
		int max = x;//1、--> int max = y;
		if(x>y) { 
			max = y;//2、--> max = x;
			return max;
		}
		return max;
	}

测试顺序1:

Input 3,5,测试失败,修改1、后,测试通过,继续测试Input 5,3,测试失败,修改2、测试通过。

此时认为程序有两个Fault

测试顺序2:

Input 5,3,测试失败,修改1、后,测试失败,修改2、后,测试通过;继续测试Input 3,5,测试通过。

此时认为程序只有一个Fault

  • Fault干扰(Fault Interference):
        //正确示例
	int maxR(int x, int y,int z) {
		if(x>y) { 
			y = x;
		}
		if(y>z) {
			z = y;
		}
		return z;
	}
	//错误示例1
	int maxW1(int x, int y,int z) {
		if(x>y) { 
			y = x;
		}
		if(y<z) { // --> if(y>z) 
			z = y;
		}
		return y; // --> return z;
	}
	//错误示例2
	int maxW2(int x, int y,int z) {
		if(x>y) { 
			y = x;
		}
		if(y<z) { // --> if(y>z) 
			z = y;
		}
		return z;
	}

 

正确示例

错误示例1

错误示例2

Input 2,5,3

测试通过

测试通过

测试失败

Input 2,3,5

测试通过

测试失败

测试失败

 

错误示例1中,第二个Fault干扰了第一个Fault导致第一个测试Pass

 

(悄悄告诉你们 “Fault是什么” 这个问题,没人知道)

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值