Mutational Tests (aka Phased Tests) is a framework, built upon TestNG, that allows test scenarios to "mutate". This means that a given scenario can, when needed,change its structure and order, i.e. “mutate”, to address the challenges that are imposed on it.
The mutational test methods help solve problems such as:
- Software Migration testing
- Software Upgrade testing
- Chaos testing
- End-User testing
This root document covers the concepts shared by both authoring styles, and the shared engine reference (execution modes, run-time configuration, reporting, data management). The two authoring guides live with their modules:
- Mutational Testing — the recommended, inheritance-based style.
- Phased Testing (TestNG) — the legacy, annotation-driven style.
- Architecture
- Problem Statement
- Authoring a Scenario
- Installation
- Demo
- Event Management and Execution
- Execution Modes and Configuration
- Execution Modes
- Run Time Properties
- MUTATIONAL.EXECUTION.MODE
- PHASED.TESTS.PHASE (DEPRECATED)
- MUTATIONAL.EVENTS.NONINTERRUPTIVE
- PHASED.EVENTS.NONINTERRUPTIVE (DEPRECATED)
- MUTATIONAL.EVENTS.TARGET
- PHASED.EVENTS.TARGET (DEPRECATED)
- PHASED.TESTS.DATABROKER
- PHASED.TESTS.STORAGE.PATH
- PHASED.TESTS.OUTPUT.DIR
- PHASED.TESTS.RETRY.DISABLED
- PHASED.TESTS.REPORT.BY.PHASE_GROUP
- PHASED.TESTS.CODE.ROOT
- PHASED.TESTS.DETECT.ORDER
- PHASED.TESTS.NONPHASED.LEGACY
- Executing a CONSUMER phase based on the PRODUCED Data
- Execution Order
- Running Nested Phased Tests
- LEGACY PHASES - DEPRECATED
- Integrity between Steps and Scenarios
- Reporting
- Known Issues and Limitations
- Release Notes
As of version 9.0.0, this repository is a multi-module Maven build. There are two ways to author a mutational test scenario, sharing one common engine:
graph BT
core["<b>phased-testing-core</b><br/>shared engine: scenario/step management,<br/>execution modes, produce/consume,<br/>events, reporting — no authoring-model opinion"]
testng["<b>phased-testing-testng</b><br/>annotation-driven authoring:<br/>@PhasedTest, @PhaseEvent,<br/>PhasedTestListener"]
mutational["<b>mutational-testing</b><br/>inheritance/template-method authoring:<br/>extend Mutational, plain step methods,<br/>MutationListener"]
testng --> core
mutational --> core
mutational-testingis the recommended, inheritance/template-method authoring style: your test class extendsMutational, its step methods are plain (non-@Test) methods, and a single template method drives their execution — including running them in every valid permutation. This is documented in Mutational Testing.phased-testing-testngis the original, annotation-driven authoring style: you write a plain class, annotate it@PhasedTest, and TestNG discovers and runs each@Teststep method directly. This is documented in Phased Testing (TestNG).- Both styles share the same underlying engine (
phased-testing-core): the same execution modes, the sameproduce/consumecontext API, the same event model, and the same reporting.
You only need to depend on the module matching the authoring style you use — see Installation.
Neither phased-testing-testng nor mutational-testing depends on the other.
Mutational Tests (aka Phased Tests) is a framework, built upon TestNG, that allows test scenarios to "mutate". This means that a given scenario can, when needed,change its structure and order, i.e. “mutate”, to address the challenges that are imposed on it.
The mutational test methods help solve problems such as:
- Software Migration testing
- Software Upgrade testing
- Chaos testing
- End-User testing
Mutations are currently of the following types:
- Events: Events taking place during the execution of tests
- Permutations: The user may take a different path than originally intended
- None : The normal execution of tests (no mutations)
Our philosophy is that normal tests should be able to run as they are, but when needed, they should be able to adapt to the situation. A test will be executed as usual on a day-to-day basis, and will test a given functionality. However, when required, it will adapt, and change the way it is executed, in order to help us better test our products.
This framework was originally, and was created to address the issues related to Events in a system. Event Based Testing is a notion where tests adapt to external events, and allow you to simulate how your product reacts to an external event. We identify two types of events:
- Interruptive events are cases such as system & application upgrades, system migrations and dependant service upgrades.
- Non-Interruptive events are cases such as system restarts, load injections and other unexpected events.
The mutational tests allow us to assess the effect of an event on a scenario no matter where along the scenario execution it takes place.
Interruptive events are cases such as system & application upgrades, system migrations and dependant service upgrades. Where the whole system requires a down-time in order to perform these events. This library allows you to define tests in such a way, so that they can be interrupted at any point awaiting an event, and to carry on where they left off. More specifically based on your design the Phased tests will ensure that a scenario will work on an upgraded system no matter where it is interrupted.
This process can be used for validating :
- Upgrades
- Migrations
- Time-Consuming external Data process
Phased Testing, when testing Interruptive events breaks down and reexecutes the tests in the way shown below:
If we want to simulate all the use cases for a workflow of a user we will end up with too many duplicate code. This is why we came up with Phased Testing, which allows a scenario to cover all the possible steps in which a workflow can be interrupted.
Non-Interruptive events are cases such as system restarts, load injections and other unexpected events. These events do not require the whole system to restart.
A typical use case for non-interruptive event is chaos testing.
This process can be used for validating resilience due to the injection of events during the execution of a scenario. Examples are
- Real-time Upgrades
- Load surges during the execuion of a scenario
- A driverless car that needs to react to a sudden event
Permutations is the process of detecting all the possible paths a scenario can take. This is done by identifying the dependencies between each step, and creating the possible orders of that scenario.
Mutationa testing allows us to make sure that all possible permutations of a scenario is checked.
This is particularily usefull for covering all the possible paths a functional scenario can take.
None refers to the absence of a mutation. A scenario that is not currently being affected by an Event or a Permutation runs exactly as it was written, i.e. in its normal, unmutated order.
This is the default state of any scenario, and is internally represented by ExecutionMode.STANDARD. Every scenario can run in this mode day-to-day, and only mutates into an Event or a Permutation when the corresponding conditions are triggered.
Whatever mutation a scenario is subject to, the authoring model underneath is the same: a scenario is a class, and its steps are the methods of that class. This is the one structural invariant shared by both authoring styles. Because steps are clearly separated methods with clear boundaries, the engine can reorder them, interrupt between them, and inject events around them.
Steps communicate through a shared context using PhasedTestManager.produce(...) and
PhasedTestManager.consume(...). This produce/consume relationship is what lets the engine store state
across an interruption, and what it analyses to work out which orderings of a scenario are valid.
The two modules differ only in how you declare that class and those steps:
| Mutational Testing (recommended) | Phased Testing (TestNG) (legacy) | |
|---|---|---|
| Authoring style | Inheritance / template-method | Annotation-driven |
| Test class | extends Mutational |
Plain class annotated @PhasedTest |
| Steps | Plain public methods (no @Test) |
Discovered as TestNG @Test methods |
| Step execution | Driven reflectively by Mutational.scenario(...) |
Run directly by TestNG |
| Listener | MutationListener |
PhasedTestListener |
| Step ordering | Always code-detected from produce/consume | Alphabetical by default, code-detected opt-in |
| Permutations | First-class | Not the primary use case |
| Artifact | mutational-testing |
phased-testing-testng |
Both share the same core engine, so the execution modes, run-time configuration, reporting and data management below apply identically regardless of the module you pick.
This version runs with the TestNG runner. You can use this library by including it in your project.
As of version 9.0.0, the project is split into multiple Maven modules sharing a common core engine
(phased-testing-core), so that the annotation-driven "Phased Testing" authoring model and the
inheritance/template-method-driven "Mutational Testing" authoring model can be released and depended on
independently. phased-testing-core is a transitive dependency of both and does not need to be declared
explicitly.
If you write tests using the Mutational base class (inheritance/template-method model, permutations,
MutationListener), add:
<dependency>
<groupId>com.adobe.campaign.tests.phased</groupId>
<artifactId>mutational-testing</artifactId>
<version>9.0.0</version>
</dependency>
If you write tests using the classic @PhasedTest annotation model (PhasedTest, @PhaseEvent,
PhasedTestListener, PhasedDataProvider), add:
<dependency>
<groupId>com.adobe.campaign.tests.phased</groupId>
<artifactId>phased-testing-testng</artifactId>
<version>9.0.0</version>
</dependency>
You can declare both dependencies together if your project uses both authoring styles.
We have a standard demo that can be accessed through the Phased Test Demo.
Events are an important topic, and have to be correctly covered. An event in Mutational Testing contains three parts:
- StartUp - the event is initiated.
- waitTillFinished - the event has finished executing
- tearDown - the system is set to a stable state
These parts of an event allow us to pilot the event injection around the scenario.
For now we identify two different event wrappings:

There are other wrappings, and we will eventually publish them at a later time.
How you attach an event to a scenario depends on the authoring style: the annotation-driven approach is covered in Binding an Event to a Scenario, and the property-driven approach in Non-Interruptive Events (Mutational).
This chapter covers the shared engine configuration used by both authoring styles — Phased and Mutational tests are both executed and configured the same way. We are able to run tests in phases since each step stores the information needed for the following steps. For now this is done at the discretion of the developer. This storage is important as it helps us keep track of the tests:
Managing this data is obviously essential to the Phased Tests. We will discuss this in more detail in the chapter on "Managing Phased Data".
We currently have 4 execution modes:
- STANDARD
- INTERRUPTIVE
- NON-INTERRUPTIVE
- PERMUTATIONAL
The execution mode is set by passing the config value "MUTATIONAL.EXECUTION.MODE" at execution time.
Some execution modes have a notion of a "behavior" which add more details to the system as to how the tests should be executed. The behavior is set by passing the behavior within parenthesis.
This is the default execution mode. By default, we execute the scenario in the order and manner in which it was defined.
The INTERRUPTIVE execution mode simulates the system being subject to an interruptive event.
The Phased Testing framework was originally devised for Interruptive Events, i.e. you need to stop a system so that you can perform some system change, such as an upgrade, to that system. Once the upgrade is done, we expect that the users can carry on with what they were doing.
The execution of steps in interruptive events is divided into two phases/behaviors depending on their execution relative to the interruptive event. The phase before the event is called “producer”, because the steps executed before the event produce data used after the event has taken place. Similarly, the phase after the event is called “consumer” because the steps rely on data created in the phase before the execution of the event.
| NAME | When Passing | Description |
|---|---|---|
| PRODUCER | INTERUPTIVE(PRODUCER) | The tests will stop before we execute the event. The tests prepare data to be used in the following test phase. |
| CONSUMER | INTERUPTIVE(CONSUMER) | The tests will continue where they left off after the event has finished. The tests consume the data produced in the previous phase. |
A NON-INTERRUPTIVE execution mode is used when we want to inject an event in the middle of the execution of a scenario. Non-Interruptive events allow us to see the effects of parallel events.
This execution mode is a good way of performing chaos testing.
This mode is activated by setting the environment variable "MUTATIONAL.EXECUTION.MODE" to "NON-INTERRUPTIVE".
The event can be piloted with the following behaviors:
We have now introduced the PERMUATIONAL execution mode. This execution mode executes a scenario with all possible permutations it can have. This is done by identifying the dependencies between each step, and creating the possible orders of that scenario.
For example, below you can see a normal scenario being executed in the standard mode:
When executed in the PERMUATIONAL mode is is executed in all possible orders:
This mode is activated by setting the environment variable "MUTATIONAL.EXECUTION.MODE" to "PERMUATIONAL".
We have the following system properties:
- MUTATIONAL.EXECUTION.MODE
- PHASED.TESTS.PHASE (Deprecated)
- MUTATIONAL.EVENTS.NONINTERRUPTIVE
- PHASED.EVENTS.NONINTERRUPTIVE (Deprecated)
- MUTATIONAL.EVENTS.TARGET
- PHASED.EVENTS.TARGET (Deprecated)
- PHASED.TESTS.DATABROKER
- PHASED.TESTS.STORAGE.PATH
- PHASED.TESTS.OUTPUT.DIR
- PHASED.TESTS.RETRY.DISABLED
- PHASED.TESTS.REPORT.BY.PHASE_GROUP
- PHASED.TESTS.CODE.ROOT
- PHASED.TESTS.DETECT.ORDER
- PHASED.TESTS.NONPHASED.LEGACY
This property is used to set the execution mode of the Phased Tests. The value can be one of the following:
- STANDARD (Or not setting any mode) : By default we execute all the steps in a mutational test, unless the @PhasedTest has set the attribute executeInactive to "false"
- INTERRUPTIVE(PRODUCER) : The tests will stop before we execute the event. The tests prepare data to be used in the following test phase.
- INTERRUPTIVE(CONSUMER) : The tests will continue where they left off after the event has finished. The tests consume the data produced in the previous phase.
- NON-INTERRUPTIVE : The tests will execute in a non-interruptive mode. This means that the tests will be executed in parallel with an event.
- PERMUATIONAL : The tests will execute in all possible orders.
We have four phased states:
- PRODUCER : We produce information
- CONSUMER : We consume information
- ASYNCHRONOUS : We execute an event during a phase.
- NON_PHASED : By default we execute all the steps in a phased test, unless the @PhasedTest has set the attribute executeInactive to "false"
This property is passed whenever we want to specify a non-interruptive event at run time. By passing the full name of the non-interruptive event, we can tell the system around which event our tests should be wrapped.
As of version 9.0.0, this has been renamed to MUTATIONAL.EVENTS.NONINTERRUPTIVE. The old property name is still honored for backward compatibility (a deprecation warning is logged), but will be removed in a future major version.
This property allows us to inject an event into a specific step of a scenario, as described in Targeting an Event to a Specific Step. The notation is either the standard method reference, or that of Surefire.
As of version 9.0.0, this has been renamed to MUTATIONAL.EVENTS.TARGET. The old property name is still honored for backward compatibility (a deprecation warning is logged), but will be removed in a future major version.
This parameter allows you to tell the PhaseTestManager which DataBroker implementation you want to use. The is usually a full class path (package name + class name). More on this will be dealt with in the chapter on Phased Data Broker.
This is the path in which the Phased Data is stored, and fetched. If not set, the path /phased_output/phased_tests/phaseData.properties will be used.
By default, Phased Test data is stored under the directory phased_output. You can override this by setting this system property. If not set, the default directory phased_output will be used.
By default, we deactivate retry analyzer for the phased tests. However, if you really want to use your retry listener, we can stop the phase test listener from deactivating it.
By default, we do not modify reports. Each step in a scenario is reported as is. We have introduced a "Report By Phase Group" functionality, which is activated with this property.
As of version 7.0.11, we will be detecting the order based on the code. These rules are deduced by analyzing the test code. Since it is not easy to deduce, we require the user to set the root directory from whoch the sources can be found. This directory should point to le location from which the first package directory starts.
As of version 7.0.11, we will be detecting the order based on the code. In 7.0.11, whenever this system property is set (the value is not important in this version), we execute the steps of a scenario based on their position within the class.
For versions < 8.0.0 we had a bug where the default execution mode was executed in a phase group called "phased-data-provider-single". This was incorrect, and as of version 8.0.0 the default execution mode of a phased test is "phased-default". Due to backward compatibility, we allow users to keep the old mode if they chose to.
Usually when your test code is in the repository of the product being tested, you will be having a delta in tests between two versions N & N+1. In such cases you will want to only execute the tests that exist in both versions.
For this, as of version 7.0.9, we have introduced the functionality that allows you to automatically select the phased tests that were executed in a previous phase. This means that when activated in a CONSUMER Phase, the selection is made based on the tests that were executed in the PRODUCER Phase. This functionality is activated when you pass or include the test group PHASED_PRODUCED_TESTS.
By default, the phased tests, being implemented in TestNG follow the same rules as that test framework. This means that up to version 7.0.10 (included), the execution of the steps in a scenario follows an alphabetical rule.
As of version 8 we have implemented code based order. Whenever the system property, PHASED.TESTS.DETECT.ORDER is set, the steps are executed in the order the way we declared in the code. By default, we expect the code to be in maven where the tests are in the directory src/test/java. However, this can be overriden by setting the execution property PHASED.TESTS.CODE.ROOT.
Nested class tests are usually quite tricky in Surefire because dollar sign '$' used for identifiying these object needs to be escaped. You can run a nested tests in the following way:
```mvn clean test -Dtest='PhasedTestSeries_NestedContainer$PhasedScenario1'```
or
```mvn clean test -Dtest=PhasedTestSeries_NestedContainer\$PhasedScenario1```
Historically Phased Tests were written for INTERRUPTIVE events so the execution reflected this behavior. As we are now expanding and revising the notion of Mutational Tests, we have need to use the Execution Modes Instead.
We do however still support the old Phased Tests until version 9.X.2.
Phases are directives at execution time, where we let the system know, in what way we want our tests to interact with an event.
We have four test phases:
- Producer In this Interruptive mode, the tests will stop before we execute the event. The tests prepare data to be used in the following test phase.
- Consumer In this Interruptive mode, the tests will continue where they left off after the event has finished. The tests consume the data produced in the previous phase.
- Asynchrounous In this Non-Interruptive mode, the events are executed in parallel to a step.
-
- Non-Phased In this state, we have not designated a state, as such, if not unwanted, we execute all tests.
Although we try to keep the execution of a scenario like any other test scenario, we feel that it is useful to document how the state of a scenario works.
Whenever a scenario step fails the following steps are marked as SKIPPED.
If a phase is not executed, the steps in the next phase are also SKIPPED.
The way data is stored between two phases is in two ways:
- Simple properties file (Default)
- Phased Data Broker
At the end of the producer phase we store all the phase data in a properties file. By default it is stored under: /phased_tests/phaseData.properties
When going to the consumer state all you need to do is to make sure that the file is available.
You can override the directory by setting the system property PHASED.TESTS.STORAGE.PATH.
In this edition we have introduced the concept of a Phased Data Broker. This allows you to define how you want your phase data to be stored. The PhasedData listener still stores a local copy, but it will in fact use a broker that you have defined.
For this you need to define a Class that implements the interface com.adobe.campaign.tests.integro.phasedPhasedDataBroker.
The Phased Data Broker can then be attached to the test in three ways (in descending order):
- Setting a system property PHASED.TESTS.DATABROKER with the class full name.
- Configuring the property PHASED.TESTS.DATABROKER as a Test Suite parameter
- Programmatically by calling PhasedTestManager.setDataBroker()
In this chapter we discuss the test reports. We currently have two types of reports:
- Default Reports - Report By Phase Group and Scenario
- Raw Reports
To make the reports a bit less messy, we introduced a report where, we only keep one result per Phase Group and Scenario. Technically, we keep the most pertinent result.
These are the end results of a phased scenario and its Phase Group:
| PRODUCER Phase Passed | CONSUMER Phase Passed | End Result |
|---|---|---|
| TRUE | TRUE | PASSED |
| FALSE | TRUE | SKIPPED |
| TRUE | FALSE | FAILED |
The following use cases exist for a phase group.
- If all steps succeed, we keep the first step as the end result.
- If in the current phase we have a failure at step X, we only keep that step result. All following steps are discarded from the result.
- If the phase group had failed in the previous phase, we keep the first step result which is "skipped". When failing due to a failure in the PRODUCER Phase, the skip message will contain the step and the phase in which the failure occurred.
- Whenever an exception is encountered in a step, it is enriched with the step name and the phase in which it happened.
- The duration we report will be the full duration of the scenario which includes the steps on both phases.
The default behavior is we just show the phase group name. This can, however be configured. We will describe this process in more detail in the chapter on how we can configure the Merged Reports.
As of version 7.0.10 this report mode is the default report mode.
By default, we store the Phase Groups whenever a Phased Test is run. However, we now have the possibility to override this. This is done by using the class PhasedTestManager.MergedReportData.configureMergedReportName(Prefix Elements, Prefix Elements). This allows users to specify the Phased Test output.
The following configuration items can be added to the constructed name:
- Phase adds the phase name to the constructed method name
- Phase Group adds the phase group to the constructed method name
- Scenario Name adds the scenario name (the class) to the constructed method name
- Data Provider add the data providers, separated by "_" to the name
We sometimes need to have an un polished report for debugging reasons. Therefore, we have introduced a raw report mode.By default, we only slightly modify how TestNG generates reports. As each step is a method, you will get one result per step. This will lead to a lot of results, but you will have the full overview of the evolution of the tests.
To activate this report, you need to set the system property PHASED.TESTS.REPORT.BY.PHASE_GROUP to "false".
In this chapter we will share the functionalities that yet need to be implemented or fixed in the Phased Testing system. In most cases these issues are items which have not yet been tested, and we yet do not know or have not specified how they should work when we are in a phased execution.
For now, we do not know how parallel execution will work with phased tests. So ideally it is best to be avoided in this context.
For now, we have not come around to deciding how retry should work in the case of phased tests. By default, we deactivate them on the phased tests unless the user specifically chooses to activate them by setting the system property PHASED.TESTS.RETRY.DISABLED to false.
See CHANGELOG.md for the full version history.




