ArticleslgStudy

computer science

Metamorphic testing

Metamorphic testing is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Metamorphic testing rather than just read about it. In short: Metamorphic testing (MT) is a property-based software testing technique, which can be an effective approach for addressing the test oracle problem and test case generation problem. The test oracle problem is the difficulty of determining the expected outcomes of selected test cases or to determine whether the actual outputs agree with the expected outcomes.

Key takeaways

  • Metamorphic testing belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Metamorphic testing to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Metamorphic testing from memory before moving on to harder problems.

Reference excerpt

Metamorphic testing (MT) is a property-based software testing technique, which can be an effective approach for addressing the test oracle problem and test case generation problem. The test oracle problem is the difficulty of determining the expected outcomes of selected test cases or to determine whether the actual outputs agree with the expected outcomes. Metamorphic relations (MRs) are necessary properties of the intended functionality of the software, and must involve multiple executions of the software. Consider, for example, a program that implements sin x correct to 100 significant figures; a metamorphic relation for sine functions is "sin (π − x) = sin x". Thus, even though the expected value of sin x1 for the source test case x1 = 1.234 correct to the required accuracy is not known, a follow-up test case x2 = π − 1.234 can be constructed. We can verify whether the actual outputs produced by the program under test from the source test case and the follow-up test case are consistent with the MR in question. Any inconsistency (after taking rounding errors into consideration) indicates a failure of the program, caused by a fault in the implementation. MRs are not limited to programs with numerical inputs or equality relations. As an example, when testing a booking website, a web search for accommodation in Sydney, Australia, returns 1,671 results; are the results of this search correct and complete? This is a test oracle problem. Based on a metamorphic relation, we may filter the price range or star rating and apply the search again; it should return a subset of the previous results. A violation of this expectation would similarly reveal a failure of the system. Metamorphic testing was invented by T.Y. Chen in a technical report in 1998. Since then, more than 750 papers have been published by international researchers and practitioners, working further on the theory and practice of MT in real-life applications. Some examples include web services, computer graphics, embedded systems, simulation and modeling, machine learning, decision support, bioinformatics, components, numerical analysis, compilers, and even quantum computing The first major survey of MT was conducted in 2016. It was followed by another major survey in 2018, which highlights the challenges and opportunities and clarifies common misunderstandings. Although MT was initially proposed as a software verification technique, it was later developed into a paradigm that covers verification, validation, and other types of software quality assessment. MT can be applied independently, and can also be combined with other static and dynamic software analysis techniques such as proving and debugging. In August 2018, Google acquired GraphicsFuzz, a startup from Imperial College London, to apply metamorphic testing to graphics device drivers for Android smartphones.

See also Mutation testing Property testing QuickCheck

References

External links "Metamorphic testing: Introduction and applications". ACM SIGSOFT Webinar. Segura, Sergio; Zhi Quan Zhou (2018). ICSE 2018 technical briefing on metamorphic testing. International Conference on Software Engineering (ICSE 2018). doi:10.5281/zenodo.1256230. Zhi Quan (George) Zhou (9 April 2019). Automated testing of real-life self-driving systems and beyond: Keynote speech. IEEE International Conference on Artificial Intelligence Testing (AI Test 2019). San Francisco East Bay, CA, USA. doi:10.5281/zenodo.2636979.

Worked examples

Example 1 — a first encounter with Metamorphic testing

Start with the simplest possible case. Write down what Metamorphic testing claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Metamorphic testing before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Metamorphic testing ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Metamorphic testing

In research
Metamorphic testing appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Metamorphic testing in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Metamorphic testing is common in secondary-school and first-year university syllabi. It links to neighbouring topics Software testing, so understanding it makes those chapters shorter.
In everyday life
Look for Metamorphic testing outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Metamorphic testing” →

How to study Metamorphic testing in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Metamorphic testing means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Metamorphic testing out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Metamorphic testing in simple terms?

Metamorphic testing (MT) is a property-based software testing technique, which can be an effective approach for addressing the test oracle problem and test case generation problem. The test oracle problem is the difficulty of determining the expected outcomes of selected test cases or to determine…

Why does Metamorphic testing matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Metamorphic testing?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Metamorphic testing.

Tags

  • Software testing

Keep exploring