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
- Architecture
- Problem Statement
- Installation
- Demo
- Wrapping a Secnario around an Event
- Event Management and Execution
- Writing a Phased Test
- Writing a Mutational Test
- 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
- Misc
- 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:
phased-testing-core (shared engine: scenario/step management, execution modes,
produce/consume, events, reporting — no authoring-model opinion)
^ ^
| |
phased-testing-testng mutational-testing
(annotation-driven authoring: (inheritance/template-method authoring:
@PhasedTest, @PhaseEvent, extend `Mutational`, plain step methods,
PhasedTestListener) MutationListener)
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 Writing a Phased Test.mutational-testingis a newer, 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 Writing a Mutational Test.- 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
- Standard : 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.
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 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>
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>
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.
One of the main features of Phased Testing is the ability to wrap a scenario around an event or a problem. This is done by performing a number of iterations and injecting the event at different stages of the execution of that scenario.
We have three modes of execution of a Phased Test:
- Default Mode
- Single Mode
- Shuffled Mode
The steps of each scenario are executed like any other scenario in a linear predicted fashion.
Single Execution Mode is used only when a workflow will always be interrupted at a given stage. This is particularly relevant when your scenario will expect a time concuming external process to finish. In this case we execute all steps till the Phase End marker. When in Consumer mode, we execute the rest of the steps.
The diagram above represents what will be executed by the following code:
@Test
@PhasedTest
public class ShuffledTest {
public void step1(String val) {
PhasedTestManager.produce("step1Val","A");
}
public void step2(String val) {
String l_fetchedValue = PhasedTestManager.consume("step1Val");
PhasedTestManager.produce("step2Val",l_fetchedValue + "B");
}
@PhaseEvent
public void step3(String val) {
String l_fetchedValue = PhasedTestManager.consume("step2Val");
assertEquals(l_fetchedValue, "AB");
}
}The concept of “shuffling” involves the multiple re-executions of a scenario, based on a stimulus or a requirement. In the case of Upgrades, the shuffling is based on the possible interruptions a scenario can be subject to whenever an upgrade happens.
Each re-execution or iteration is identified by what we call a Shuffle Group. The Shuffle Group also acts as a context in which the steps have a relationship and share context variables.
The code below will react differently depending on the PHASE/Execution mode it is subject to :
@Test
@PhasedTest
public class ShuffledTest {
public void step1(String val) {
PhasedTestManager.produce("A1");
}
public void step2(String val) {
String l_fetchedValue = PhasedTestManager.consume("A1");
PhasedTestManager.produce("B1",l_fetchedValue + "B");
}
public void step3(String val) {
String l_fetchedValue = PhasedTestManager.consume("B1");
assertEquals(l_fetchedValue, "AB");
}
}When a shuffled test is executed in an interruptive mode (Phases PRODUCER and CONSUMER), we execute all the possible ordered combinations interruptions the scenario can be subject to. Example Given a test with three steps, in Producer State, we :
- Execute all the three steps
- Execute the first two steps
- Execute the first step only
When in Consumer state we :
- Execute the two last steps
- Execute the last step
- Execute all the steps
As of version 8, we are introducing the asynchronous phase mode. Asynchronous phases are destined for non-interruptive events. They allow you to inject an event during the execution of the steps of a scenario. An asynchronous execution of a shuffled test, will shuffle the test, but will for each phase group execute, in parallel, the given event for each step.
Example:
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.
This is the annotation-driven authoring model, provided by the phased-testing-testng module. Your test
class is a plain TestNG class discovered and run directly by TestNG.
You need to register PhasedTestListener for phased tests to be recognized, either on your suite in
testng.xml:
<suite name="My Suite">
<listeners>
<listener class-name="com.adobe.campaign.tests.integro.phased.PhasedTestListener"/>
</listeners>
...
</suite>or with the @Listeners annotation on your test class.
The Phased Testing is activated using two annotations:
- @PhasedTest : Class level annotation. Allows you to control how the test should be executed
- @PhaseEvent : Method level annotation. By setting it you tell the system at which step does the phase event happen. The tests will stop at that point.
Moreover, you need to :
- Make your methods accept at least one argument
- Due to the TestNG standards, the methods will be executed, by default in an alphabetical order. So prefixing the methods with their step number is a good practice.
Note : As of version 7.0.11, we now have the possibility to let the framework pick the order for us.
In order for a test scenario to be executed in shuffle mode you need to add the following annotation at the class level @PhasedTest
In order for a test scenario to be executed in shuffle mode you simply need to set the annotation @PhaseEvent somewhere along its steps. The location of this annotation is where you expect the interruption to occur..
Optionally if you consider that the scenario can never be run as non-phased, you need also include: @PhasedTest(executeInactive = false). When executeInactive is false, the Single Run scenario will only run when in Phases.
Ideally you should set the default data provider on your tests. This allows you to execute the test locally without needing to force the Phased Test listener.
@Test( dataProvider = PhasedDataProvider.DEFAULT, dataProviderClass = PhasedDataProvider.class)
@PhasedTest
public class MyPhasedTest {
}
However, whenever the Phased Test Listener discovers a Phased Test, it will add the necessary data providers needed for running the test. But, ideally it is best to set the default providers in orrder to not lose the possibility of local execution.
In the case of non-interruptive events there are a few things to consider:
- Writing an Event
- Binding an Event to a Scenario
In order have some level of predictability for non-interruptive events, we have defined an api for non-interruptive events. For an event to be able to be used by the Phased Tests it needs to inherit from the abstract class com.adobe.campaign.tests.integro.phased.NonInterruptiveEvent which extends Runnable.
In the example before we have created an event NonInterruptiveEventExample:
public class NonInterruptiveEventExample extends NonInterruptiveEvent {
@Override
public boolean startEvent() {
return false;
}
@Override
public boolean isFinished() {
return false;
}
@Override
public boolean waitTillFinished() {
return false;
}
}As you can see we have to implement three methods:
startEventstarts the event.isFinishedallow the system to see if the event we declared has finished.waitTillFinishedwaits until the event has finished.
In order to define these event you will need to implement these methods, as you who are defining the event have the best knowledge on how these event will work.
At times the simple execution of an event is not sufficient. We need to perform an event clean up action to reset the system to a stable state. For this we allow you to define a 'tearDownEven' actions for an event. This means that after an event has been finished, we perform an additional set of actions before the next step is executed. To make use of this you need to override the method tearDownEvent in your event. The framework will then execute this action right before the next step is triggered.
@Override
public boolean tearDownEvent() {
// Perform actions
return true; //Return true if the actions were successful
}In order for your scenario to interact with an event you will need to declare it. This can be done in three ways (in order of precedence) :
- Phased Event Annotation
- Phased Test Annotation
- Test Suite Definition
If you have the event declared in more than one level (for example on both the PhasedEvent and the PhasedTest annotation), it is the value with more precedence which is taken into account.
The mode is only applicable to Single Run execution modes.
In the case of single run scenarios, we can specify which phase event should be triggered on the annotation itself. This is by setting the eventClasses attribute for the @PhaseEvent annotation.
In the example below the PhaseEvent is always executed at the step2 of the scenario. Here we have specified that when we are in asynchroous mode only the event com.adobe.campaign.tests.integro.phased.data.events.MyNonInterruptiveEvent should be executed.
@PhasedTest
@Test
public class SingleRunScenarioWithEvent {
public void step1(String val) {
PhasedTestManager.produceInStep("A");
}
@PhaseEvent(eventClasses = {"com.adobe.campaign.tests.integro.phased.data.events.MyNonInterruptiveEvent"})
public void step2(String val) {
String l_fetchedValue = PhasedTestManager.consumeFromStep("step1");
PhasedTestManager.produceInStep(l_fetchedValue + "B");
}
public void step3(String val) {
String l_fetchedValue = PhasedTestManager.consumeFromStep("step2");
assertEquals(l_fetchedValue, "AB");
}
}In this case we expect us to specify if a scenario is only subject to the same event. This will be done at the @PhasedTest annotation using the attribute eventClasses. When set we only use the specified event.
@PhasedTest(eventClasses = {"com.adobe.campaign.tests.integro.phased.data.events.MyNonInterruptiveEvent"})
@Test
public class ShuffledScenarioWithEvent {
public void step1(String val) {
PhasedTestManager.produce("step1Value","A");
}
public void step2(String val) {
String l_fetchedValue = PhasedTestManager.consume("step1Value");
PhasedTestManager.produce("Step2Value", l_fetchedValue + "B");
}
public void step3(String val) {
String l_fetchedValue = PhasedTestManager.consume("Step2Value");
assertEquals(l_fetchedValue, "AB");
}
}In this case, we state that all scenarios should be using the same Event. We can activate this mode by setting the environment variable MUTATIONAL.EVENTS.NONINTERRUPTIVE to the event class.
This works for both Shuffled and Single-Run tests. If we want to run all tests with the event com.adobe.campaign.tests.integro.phased.data.events.MyNonInterruptiveEvent, we enter:
mvn clean test -DMUTATIONAL.EVENTS.NONINTERRUPTIVE=com.adobe.campaign.tests.integro.phased.data.events.MyNonInterruptiveEvent
You can also add it as a property in your testng definition file.
As of version 8.11.2, we can inject an event to a specific step of a Phased Scenario. This is done by:
- Declaring an event by setting the variable
MUTATIONAL.EVENTS.NONINTERRUPTIVE. - Identifying the step on which an event will occur. This is done by setting the variable
MUTATIONAL.EVENTS.TARGET.
The step should point to a method. For method step1 in the class a.b.c.ScenarioA you can set:
a.b.c.ScenarioA.step1ScenarioA#step1ScenarioA.step1
In the case of nested tests, for method step1 in the class a.b.c.ScenarioA, and sub-class NestedClassB you need to use the $ notation. It will look like:
a.b.c.ScenarioA$NestedClassB.step1ScenarioA$NestedClassB#step1ScenarioA$NestedClassB.step1
Here is an example of running a specific event for a specific test:
mvn clean test -DMUTATIONAL.EVENTS.NONINTERRUPTIVE=com.adobe.campaign.tests.integro.phased.data.events.MyNonInterruptiveEvent -DMUTATIONAL.EVENTS.TARGET=ScenarioA$NestedClassB#step1
We have introduced the possibility of defining Before and After Phases. This means that you can state if a method can be invoked before or after the phased tests are executed. These methods are only activated when we are in a Phase, and will not run when executed when we execute the scenarios in Non-Phased mode.
However, Before/After Phase methods are like any other Before/After method as, when invoked, they will affect all underlying tests, even if they are not Phased Tests.
To activate this functionality you add the annotations @BeforePhase & @AfterPhase to a TestNG configuration method such as: @BeforeSuite, @AfterSuite, @BeforeGroups, @AfterGroups, @BeforeTest and @AfterTest.
To your configuration method. Example:
@BeforePhase
@BeforeSuite
public void myBeforePhaseSuite() {
//Perform actions
}In the example above the method myBeforePhaseSuite will be invoked in the beginning of the suite. By default, the BeforePhase method is invoked when we are in a Phase I.e. Producer or Consumer.
You can configure this with the attribute appliesToPhases, which accepts an array of Phases. In the example below we are activating AfterPhase for the Consumer phase only.
@AfterPhase(appliesToPhases = {Phases.CONSUMER})
@AfterSuite
public void myAfterPhasedSuite() {
//Perform actions
}As of version 7.0.9 of Phased Testing which is based on the 7.5 of TestNG, we can now define nested Phased tests. This allows you to regroup the phased tests under the same class. Thus, you will have Phased Tests that resemble method based tests.
Example:
public class PhasedTestSeries_NestedContainer {
@Test
@PhasedTest
public class PhasedScenario1 {
public void step1(String val) {
PhasedTestManager.produce("myValX","A");
}
public void step2(String val) {
String l_fetchedValue = PhasedTestManager.consume("myValX");
assertEquals(l_fetchedValue, "A");
}
}
@Test
@PhasedTest
public class PhasedScenario2 {
public void step1(String val) {
PhasedTestManager.produce("MyVal1","AB");
}
public void step2(String val) {
String l_fetchedValue = PhasedTestManager.consume("MyVal1");
assertEquals(l_fetchedValue, "AB");
}
}
}This is the inheritance/template-method authoring model, provided by the mutational-testing
module. Unlike a Phased Test, your test class isn't a plain TestNG class run directly by TestNG — it
extends the abstract class Mutational, and a single template method on that base class (scenario)
resolves the right step order and invokes your step methods one by one, reflectively.
You need to register MutationListener for Mutational tests to be recognized, either on your suite in
testng.xml:
<suite name="My Suite">
<listeners>
<listener class-name="com.adobe.campaign.tests.integro.phased.MutationListener"/>
</listeners>
...
</suite>or with the @Listeners annotation on your test class.
Extend Mutational, and write your steps as plain (non-@Test) public methods, each accepting a single
String argument — the current phase/shuffle group. You still need a class-level @Test annotation (for
grouping, same as any TestNG class), but you do not need @PhasedTest/@PhaseEvent — Mutational
itself already carries the annotation wiring your steps need.
@Test(groups = "checkout")
public class ShoppingCartScenario extends Mutational {
public void loginToSite(String phaseGroup) {
PhasedTestManager.produce("authToken", "123456");
}
public void searchProduct(String phaseGroup) {
PhasedTestManager.produce("product", "product1");
}
public void addProductToCart(String phaseGroup) {
String product = PhasedTestManager.consume("product");
PhasedTestManager.produce("cart", "cart1");
}
public void checkout(String phaseGroup) {
PhasedTestManager.consume("authToken");
PhasedTestManager.consume("cart");
}
}Key differences from Writing a Phased Test:
- Step methods are not annotated
@Testindividually — they're plain methods discovered via reflection and invoked one by one byMutational.scenario(String). - Each step method must accept exactly one
Stringargument — the current phase/shuffle group. - The
produce/consumecontext API (PhasedTestManager.produce/consume) is exactly the same as in Phased Testing, since both authoring styles share the same core engine. - Ordering between steps is always determined from code-detected dependencies between steps (via
produce/consume) — the same underlying mechanism Phased Tests can opt into viaPHASED.TESTS.DETECT.ORDER, but for Mutational tests it's not optional, since there's no TestNG-native@Testmethod order to fall back on.
The PERMUTATIONAL execution mode is the feature most specific to
Mutational Testing: instead of picking a single valid step order, it identifies every dependency between
steps (via produce/consume) and re-executes the scenario once per valid permutation of that order. See
Permutations for the underlying concept.
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 deal with miscellaneous issues related to Phased Tests
We now allow for a user to also include data providers in connection to Phased Tests. The Data Provider parameters will, when executed in a Phased Test, be added to the test result.
A configuration check is done in the beginning. The phased test steps are checked and their arguments are compared to the number of data providers + the injected data provider for phased tests. If the number of arguments does not correspond to the total number of data providers, a PhasedTestConfigurationException is thrown right at the beginning.
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.






