A metamorphic testing approach for event sequences

Jing Chen, Yinglong Wang, Ying Guo, Mingyue JiangPLoS 2019

Abstract

Test oracles are essential for determining the correctness of software execution, yet many systems—particularly those involving complex business processes—suffer from the "oracle problem." In these cases, a reliable oracle is either unavailable or prohibitively expensive to implement. This paper proposes MTES (Metamorphic Testing for Event Sequences), a framework designed to alleviate the oracle problem by focusing on the relative consistency between sequences of events rather than absolute output correctness. Through three diverse case studies, we demonstrate that MTES is a feasible and effective method for identifying logic errors in business-process-based software.

Introduction: The Oracle Problem in Business Processes

In traditional software testing, a "test oracle" acts as the ground truth to verify if a program's output is correct. While simple for basic arithmetic, this becomes a significant bottleneck for complex business systems, such as interbank transfers or cloud autoscaling. These systems involve multi-step dependencies where defining the exact expected state for every possible permutation of events is technically challenging.

MTES addresses this by utilizing Metamorphic Testing (MT). Instead of asking "Is this output correct?", MT asks "Does the relationship between these two related inputs hold true in their outputs?" By shifting the focus to relative consistency, testers can verify system logic without a pre-defined oracle.

The MTES Framework

The MTES approach models business processes as Event Sequence Graphs (ESGs). The workflow consists of four primary stages:

  1. Modeling: Business processes are represented as sequences of discrete events (e.g., Login → Check Balance → Withdraw).
  2. Defining Metamorphic Relations (MRs): Rules are established to describe how changes in an input sequence should predictably affect the output. For instance, in a banking system, depositing $100 twice should result in the same final balance as depositing $200 once.
  3. Test Case Generation: A "source" test case is created, and an MR is applied to generate a corresponding "follow-up" test case.
  4. Verification: The system checks if the relationship between the source and follow-up outputs remains consistent. A violation of this relationship indicates a bug.

Categories of Metamorphic Relations

The study identifies three distinct types of MRs for event sequences:

  • Fixed single-event: Modifying data within a single event in the sequence.
  • Fixed multi-event: Modifying data across a static, pre-defined sequence.
  • Varied event sequences: Altering the structural composition of the sequence itself, such as inserting, deleting, or reordering events.

Experimental Evaluation

To evaluate MTES, researchers conducted three case studies across different domains:

  • Electricity Bill Payment: A Java system with tiered pricing and subsidies.
  • Interbank Transactions: A simulation of ATM and counter operations with complex fee structures.
  • Elastic Cloud Management: A real-world-style system built on OpenStack managing virtual machine scaling.

The effectiveness of the approach was measured using Mutation Testing. By injecting hundreds of small intentional bugs ("mutants") into the source code, the researchers could calculate a Mutation Score—the percentage of bugs successfully detected by MTES.

Key Insights and Results

The experimental results highlighted several critical findings for software testers:

  • Sequence Over Syntax: Structural changes to event sequences (varied sequences) were significantly more effective at uncovering deep logic errors than simply changing input data values.
  • The Diversity Principle: The most effective MRs are those that force the software to take vastly different internal execution paths for the source and follow-up cases. High path diversity correlates with higher fault detection rates.
  • High Fault Detection: In the banking case study, the most robust MRs achieved a Mutation Score of 89%.
  • Real-World Application: In the Cloud Management study, MTES identified architectural faults that traditional tests missed, including a database permission error and a GUI lag that caused autoscaling timeouts.

Conclusion and Future Directions

MTES provides a powerful alternative for testing systems where traditional oracles are impractical. By leveraging domain logic to create "pseudo-oracles," testers can achieve high fault detection with less maintenance overhead.

However, challenges remain. As business processes grow in complexity, the state-space for event permutations expands exponentially. Future research will focus on the automated identification of metamorphic relations and conducting cost-benefit analyses to optimize the number of test executions required for industrial-scale applications.

Summary updated

BibTeX
@inproceedings{chen2019metamorphic,
  author = {Jing Chen and Yinglong Wang and Ying Guo and Mingyue Jiang},
  title = {{A metamorphic testing approach for event sequences}},
  booktitle = {PLoS},
  year = {2019},
  doi = {10.1371/journal.pone.0212476},
}
Figure