下面是一個比較正式的關于蛻變測試(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)等。如果有任何違反以上關系的情況發生,那么我們就可以認定程序中存在錯誤。
文章來源于領測軟件測試網 http://www.kjueaiud.com/