Metamorphic Testing&metamorphic relationship(摘自维基百科)

以下摘自维基百科:

 Metamorphic Testing (MT)兑变测试 is a software testing technique that tries to address part of the problem of the test oracle. The Test Oracle is the mechanism by which a tester can determine if a program has failed by comparing expected output to actual output(2). Part of the problem of an automatic test oracle is that it is difficult to generate a list of expected outputs from a list of inputs. Metamorphic Testing takes a valid input with a known expect output and then creates mutations(变化,更换) of the original input to create equivalent inputs with the same original expected output. For a trivial(平凡的,微不足道的) example, suppose that a function has an input of numeric “1” with an expect output of “42”. A metamorphic relationship (MR) might be an expression such as “e^0” which is equivalent to the original input of “1”. Since the original input (“1”) and the input via metamorphic relationship(“e^0”) are the same, the function under test should have the same expected output of “42”. A different output from the function under test could indicate a bug. These constructed inputs are sometimes referred to as follow-up test cases.

MT can be used on any problem that can formulate a logical MR. Some examples of this might be an input graph for shortest path problem, CG (computer graphics), compilers, and interactive software(1). On the other hand, generation of the MR’s could be computationally expensive to produce as in the input graphs for shortest path problem.

 

以下摘自测试论坛:

下面是一个比较正式的关于蜕变测试(Metamorphic Testing)的定义:
Metamorphic testing is used in conjunction with other test case selection strategies Given a test case selection strategy S, such as path coverage, a set of test cases T ={t1,t2,t3...tn} , where is n>=1 generated. The program is then tested on T . If no failure is revealed after running all in T for i = 2, .. . , n,then T will be a set of successful test cases.

At this stage, metamorphic testing can be carried out to generate follow-up test cases according to metamorphic relations. A metamorphic relation (MR) is an expected relation among the inputs and outputs of multiple executions of the target program. For a successful test case and a chosen MR, we can construct follow-up test say ti' and run the program again. Let p denote the program under test. We check ti, p(ti),ti' and p(ti')against the MR. If MR cannot be satisfied, the program must have failed.

简而言之,蜕变测试是利用一些成功的测试用例来产生后续测试用例的一种技术,我们将后续的测试用例和前者之间的关系称作metamorphic relation(MR)。举一个很简单的例子来说,假设我们有一个计算sin函数程序(输入值为弧度),一般情况下我们可以利用一些特殊值去进行测试,比如sin(0)=0,sin(Pi/2)=1 等。但是假设我们有这么一个测试用例sin(2)其程序结果为0.909,那我们如何能判定这个结果的正确性呢?这种情况下,我们可以根据一些已知的MR去产生后续测试用例进行测试,比如sin(x)=-sin(-x),sin(x)=sin(pi-x)(这就是MR)等。如果有任何违反以上关系的情况发生,那么我们就可以认定程序中存在错误。

 

以下截图来自《兑变测试技术综述》——计算科学与探索 09年3月


 

你可能感兴趣的:(mr,mt,兑变测试)