# Metamorphic testing

Metamorphic Testing (MT)[1] is a software testing technique that attempts to alleviate the test oracle problem. A test oracle is the mechanism by which a tester can determine whether a program has failed by comparing the actual output with the expected output. A test oracle problem occurs when it is difficult to generate expected outputs from selected test cases, or when it is difficult to determine whether the actual outputs agree with the expected outputs.

Metamorphic testing takes an original test case with unknown expected output and mutates it into a “follow-up” test case. For example, the expected output of a function that computes sin x to 100 significant figures is unknown. A metamorphic relation (MR) is a necessary property of the function, such as “sin x = sin (π − x)”. Hence, the program under test should have the same expected output for an original test case “0.1234” and a follow-up test case “π − 0.1234”. If the actual outputs from the program under test for these two test cases are different, it indicates a failure of the implementation.

An MR does not need to be an equation but can be a general relation. Thus, metamorphic testing can be applied to any problem in which a necessary property can be formulated. Some examples of successful applications include partial differential equations,[2] ubiquitous computing,[3] services computing,[4] imaging software,[5] bioinformatics,[6] software product lines,[7] and web search engines.[8]

## References

1. ^ First introduced in T.Y. Chen, S.C. Cheung, and S.M. Yiu, "Metamorphic testing: a new approach for generating next test cases", Technical Report HKUST-CS98-01, Department of Computer Science, Hong Kong University of Science and Technology, Hong Kong (1998).
2. ^ T.Y. Chen, J. Feng, and T.H. Tse, "Metamorphic testing of programs on partial differential equations: a case study", in Proceedings of the 26th Annual International Computer Software and Applications Conference (COMPSAC '02), IEEE Computer Society, Los Alamitos, CA, pp. 327−333 (2002).
3. ^ T.H. Tse, S.S. Yau, W.K. Chan, H. Lu, and T.Y. Chen, "Testing context-sensitive middleware-based software applications", in Proceedings of the 28th Annual International Computer Software and Applications Conference (COMPSAC '04), vol. 1, IEEE Computer Society, Los Alamitos, CA, pp. 458−465 (2004).
4. ^ W.K. Chan, S.C. Cheung, and K.R.P.H. Leung, "A metamorphic testing approach for online testing of service-oriented software applications", International Journal of Web Services Research 4 (2): 60−80 (2007).
5. ^ R. Guderlei and J. Mayer, "Towards automatic testing of imaging software by means of random and metamorphic testing", International Journal of Software Engineering and Knowledge Engineering 17 (6): 757−781 (2007).
6. ^ T.Y. Chen, J.W.K. Ho, H. Liu, and X. Xie, "An innovative approach for testing bioinformatics programs using metamorphic testing", BMC Bioinformatics 10: article no. 24 (2009).
7. ^ S. Segura, R.M. Hierons, D. Benavides, and A. Ruiz-Cortes, "Automated test data generation on the analyses of feature models: a metamorphic testing approach", in Proceedings of the 3rd International Conference on Software Testing, Verification, and Validation (ICST '10), IEEE Computer Society, Los Alamitos, CA, pp. 35−44 (2010).
8. ^ Z.Q. Zhou, S. Zhang, M. Hagenbuchner, T.H. Tse, F.-C. Kuo, and T.Y. Chen, "Automated functional testing of online search services", Software Testing, Verification and Reliability 22 (4): 221−243 (2012).