Connect PIT to Stryker Dashboard
Until recently, it would be quite cumbersome to integrate PIT with the Stryker Mutator Dashboard. It involved (mis-) using a different PIT reporter, a fragile Bash script to fiddle around in one of the generated JavaScript files... Not pretty at all.
A first-class tool like PIT deserves a better integration with a first-class dashboard like the Stryker Mutator Dashboard!
That's why today, I am introducing a much cleaner and simpler approach: the Stryker Mutator Dashboard reporter for PIT.
Here's how it works:
- It collects mutation testing results from PIT.
- It converts the collected mutation testing results into the format that the Stryker Mutator Dashboard expects.
- It uploads the converted report to the Stryker Mutator Dashboard.
How to use it?โ
I've tried to make it as simple as possible to use the reporter.
As a prerequisite, make sure there is an environment variable STRYKER_DASHBOARD_API_KEY
with the API key that you got when you set up your project.
Now, follow these four steps:
-
Find the place in your pom.xml where you define the pitest-maven plugin.
-
Add a dependency to this plugin declaration:
<dependency>
<groupId>it.mulders.stryker</groupId>
<artifactId>pit-dashboard-reporter</artifactId>
<version>0.1.2</version>
</dependency> -
Configure PIT to use the new output format:
<configuration>
<outputFormats>
<format>stryker-dashboard</format>
</outputFormats>
</configuration>- Alternatively, if
<configuration>
is already there, add the<outputFormats>
. - Similarly, if
<outputFormats>
is already there, add (or replace) with<format>stryker-dashboard</format>
.
- Alternatively, if
-
Important If you are working on a multi-module Maven project, add the following to the
<configuration>
block:<pluginConfiguration>
<stryker.moduleName>${project.artifactId}</stryker.moduleName>
</pluginConfiguration>This will ensure the mutation testing results of the various Maven modules will not mix up in the report. You should not do this if you have a single-module Maven project!
-
For all the other things, the reporter will autoconfigure itself, given your build runs on any of the following environments:
- GitHub Actions
If your builds run in another environment, please feel free to open an issue.
That's all - you're done! Kick off a fresh build, wait a few minutes and enjoy the online report!
Creditsโ
Credit where credit is due: this reporter would not exist without this tremendous work by Wouter Aarts. His reporter contains all the complex mapping from PIT results to mutation-testing-elements' JSON format.
Post Scriptumโ
I have a slightly longer version of this blog (including some historical background) on my personal blog.