Link Search Menu Expand Document

JUnit 5 Accelerator Plugin

Requires pitest 1.7.0 or above.

Maven Central

Background

Mutation analysis times depends on many different factors which make overall execution times difficult to predict, but the execution time of the tests is always an important variable.

Although small improvements in the execution time of individual tests are of little importance when the tests are run only once within a suite, mutation testing may require each test be run thousands of times. Small speed gains can become of practical importance.

The junit5-accelerator plugin improves mutation test performance by reducing the overhead in running tests that use a limited set of JUnit Jupiter features. Tests that use only these features will run more quickly, tests that use features outside this set will be executed as normal.

For some codebases this can have a large impact on performance, e.g analysis time for Commons Lang is reduced from over 55 minutes to under 18.

Eligible tests

Tests that use the following subset of JUnit 5 Jupiter functionality will be accelerated. Any test classes using features/annotations outside of this set will be run as normal. Note that this is an “all or nothing” approach, an unsupported annotation added to one test method means no tests within that class will be accelerated.

  • @Test (parameterless methods only)
  • @BeforeEach
  • @AfterEach
  • @DisplayName (annotation is ignored)

The following mockito features are also supported

  • @Mock (on fields only)
  • @ExtendWith(MockitoExtension.class)
  • @MockitoSettings

Installation

To you use the plugin you must first acquire a licence. If you are working on an open source project you can get a free licence here. For commercial projects we are currently accepting requests for our beta programme.

The licence file must be named cdg-pitest-licence.txt and placed at the root of the project.

The plugin itself should be placed on the classpath of the pitest build integration plugin.

E.g for maven

<plugin>
  <groupId>org.pitest</groupId>
  <artifactId>pitest-maven</artifactId>
  <version>1.7.0</version>
    <dependencies>
      <dependency>
        <groupId>com.groupcdg.pitest</groupId>
        <artifactId>pitest-accelerator-junit5</artifactId>
        <version>0.0.2</version>
      </dependency>
      <dependency>
        <groupId>org.pitest</groupId>
        <artifactId>pitest-junit5-plugin</artifactId>
        <version>0.15</version> <!-- if using Jupiter 5.8.x. 0.14 for earlier versions -->
      </dependency>
    </dependencies>
</plugin>

Or for gradle

dependencies {
  pitest 'com.groupcdg.pitest:pitest-accelerator-junit5:0.0.2 number'
}