← Latest papers
💻 computer science

MR-Adopt: Automatic Deduction of Input Transformation Function for Metamorphic Testing

MR-Adopt is a novel approach that leverages large language models and data-flow analysis to automatically deduce generalizable input transformation functions from hard-coded metamorphic relations, thereby enabling their reuse with new inputs and significantly improving test adequacy.

Original authors: Congying Xu, Songqiang Chen, Jiarong Wu, Shing-Chi Cheung, Valerio Terragni, Hengcheng Zhu, Jialun Cao

Published 2026-04-14
📖 4 min read☕ Coffee break read

Original authors: Congying Xu, Songqiang Chen, Jiarong Wu, Shing-Chi Cheung, Valerio Terragni, Hengcheng Zhu, Jialun Cao

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a quality inspector for a factory that makes custom cakes. You have a recipe book (the software) and a set of test notes written by the original bakers (the developers).

The Problem: The "Hard-Coded" Recipe

Most of the time, these test notes are incredibly specific but not very useful for new situations. They look like this:

"Take a cake made on January 1st. Make a second cake for January 2nd. Check if the second cake is exactly one day older than the first."

This works great for testing those two specific dates. But what if you want to test the factory on February 29th or December 31st? The notes don't tell you how to get from the first date to the second. They just say, "Here is Date A, and here is Date B."

Because the notes don't explain the rule (the transformation), you can't automatically generate new tests. You are stuck manually writing new notes for every single date you want to test. This is a huge bottleneck. In the world of software, researchers found that 70% of these test notes are "hard-coded" like this—they have the inputs and the expected result, but they are missing the "magic formula" that connects them.

The Solution: MR-Adopt (The "Rule Detective")

The paper introduces a new tool called MR-Adopt. Think of MR-Adopt as a super-smart detective (powered by Large Language Models, or AI) whose job is to look at those specific, hard-coded notes and figure out the hidden rule.

Here is how MR-Adopt works, using a simple analogy:

Phase 1: The "Imagination Game" (Generating Examples)

If you only show the detective one example (Jan 1 \to Jan 2), they might guess the rule is "Add 1 day." But they might also guess the rule is "Change the year to 2025" because that's the only other thing that changed.

To stop the detective from guessing wrong, MR-Adopt asks the AI to imagine more examples first.

  • "Okay, if Jan 1 becomes Jan 2, what would happen if we started with June 15? Would it become June 16?"
  • "What if we started with February 28? Would it become March 1?"

By generating many of these "what-if" scenarios, the AI gets a better sense of the pattern rather than just copying the specific numbers. It's like showing a child a few examples of "adding one" before asking them to solve a new math problem, so they don't just memorize the answer.

Phase 2: The "Code Chef" (Writing the Rule)

Now that the AI has a bunch of examples (Jan 1 \to Jan 2, June 15 \to June 16, etc.), it tries to write the actual "magic formula" (the code) that turns any Date A into Date B.

However, AI chefs sometimes add extra ingredients they don't need, or even use ingredients that don't exist in your kitchen (like trying to use a "flying spoon").

  • Refinement: MR-Adopt acts like a strict head chef. It looks at the code the AI wrote and cuts out all the useless or broken parts. It keeps only the steps that actually turn the date forward.
  • Testing: Finally, it runs the new rule against many different dates (like a test kitchen). If the rule works for every date, it keeps it. If it only works for January dates, it throws it away and tries again.

The Result: A Factory That Runs Itself

Once MR-Adopt figures out the rule (e.g., "Add one day"), it can apply that rule to any date you throw at it.

  • Before: You could only test the two dates the original baker wrote down.
  • After: You can test thousands of dates automatically.

The paper shows that by using MR-Adopt:

  1. More Bugs Found: They found 18.9% more bugs (mutation score) than before.
  2. Better Coverage: They tested 10.6% more of the code (line coverage).

Why This Matters

Think of it like upgrading from a manual car to an autonomous car.

  • Old Way: You have to manually steer the car (write test inputs) for every single turn. If you forget a turn, you miss a spot.
  • MR-Adopt Way: You teach the car the rules of the road (the transformation). Now, the car can drive itself through any new street, checking for potholes (bugs) everywhere, without you needing to write down every single turn in advance.

In short, MR-Adopt takes old, rigid test notes and turns them into flexible, automatic instructions, making software testing much faster, smarter, and more thorough.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →