Reactor Strategies

Skip to end of metadata
Go to start of metadata

A reactor strategy defines a factory for creating reactors. The reactor strategy determines whether or not the test container will be stopped and restarted between tests.

The reactor strategy is defined by an annotation on the test class.

Pax Exam >= 3.0.0.M1

PerTest

With the per test strategy, the test container is started and stopped before and after each individual test method.

This strategy is only supported in OSGi mode. This strategy is synonymous with AllConfinedStagedReactorFactory (see below) which is still supported but now deprected.

PerTest is the default strategy in OSGi mode.

PerClass

With the per class strategy, the test container is started and stopped before and after running all tests of a given test class. Thus, subsequent test methods are not completely isolated from any side effects of previous methods of the same test class.

This strategy is only supported in OSGi and CDI modes. This strategy is synonymous with EagerSingleStagedReactorFactory (see below) which is still supported but now deprected.

PerSuite

With the per suite strategy, the test container is started once before running all test classes of the current probe and is stopped after the entire suite has run. This strategy minimizes the container startup and shutdown overhead at the price of no isolation and potential side effects between test classes or methods.

This strategy is only supported in Java EE and CDI modes.

PerSuite is the default strategy in these modes.

For Pax Exam, a suite is the set of all test classes of the current run. This does not in general coincide with the concept of a suite in JUnit or TestNG.

The contents of a suite is usually determined by an external runner like Maven Surefire or Eclipse. E.g. when selecting Run As | JUnit Test from the context menu of a Java package in Eclipse, then the suite will contain all classes from the given package annotated by @RunWith(PaxExam.class).

Since JUnit does not fire any before suite or after suite events, the reactor is started lazily before the first test method is executed and is stopped using a VM shutdown hook.

Pax Exam < 2.5.0

AllConfinedStagedReactorFactory

With the all confined strategy, a new test container is started and stopped for each test. Note that each test method from your test class may give rise to one or more tests, depending on the number of configurations and frameworks specified in your test class.

(For the Native Test Container, the number of frameworks is specified implicitly by the number of FrameworkFactory services found by the JDK ServiceLoader.)

This strategy is the default when no @ExamReactorStrategy annotation is found on the test class.

EagerSingleStagedReactorFactory

With the eager single strategy, the reactor starts all configured test containers before starting the first test, executes the tests in these containers and finally stops all containers after the last test has terminated.

TODO What happens when a running test crashes a container?

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Clicky Web Analytics