Can Metamorphic Relations be Automatically Discovered?

04/15/2023
by   Congying Xu, et al.
0

Metamorphic testing alleviates the test oracle problem by defining oracles based on relations (i.e., metamorphic relations) that govern multiple related inputs and their expected outputs. However, designing MRs requires domain-specific knowledge, which may not be generally available. This hinders the widespread adoption of MT. Fortunately, we observe that developers often embed such domain knowledge that encodes MRs in test cases, even without the awareness of metamorphic testing. These encoded MRs might be generalized and useful for testing the original programs (where these MRs are found) and other programs with similar functionalities. In this paper, we propose MR-Extractor, to automatically discover metamorphic relations from existing test cases in open-source software (OSS) projects. MR-Extractor firstly identifies MR-encoded test cases in OSS, and then generalizes encoded MRs and codifies them into parameterized methods (called codified MR) for MT. Finally, MR-Extractor validates the reusability of codified MRs for new test generation. Experimental results show that (i) over 12,000 MR-encoded test cases are identified by MR-Extractor, accounting for 1.26 discovered by MR-Extractor can effectively improve test coverage. Compared with developer-written test suites, codified-MR-based test suites leads to a 25.97 and 25.83 Evosuite-generated test suites, codified-MR-based test suites even achieves an 83.11

READ FULL TEXT

Please sign up or login with your details

Forgot password? Click here to reset