generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 1
Pitest Mutation Listener
Luca Böhm edited this page Dec 19, 2023
·
3 revisions
By implementing the MutationResultListener Interface, one can create a custom Mutation Result Listener (example).
In the interface there are three methods given:
- runStart: This method gets called at the start of a pitest run. We could use it to check for needed directorys and setting up data structures the our plugin needs.
- handleMutationResult: This is the most interresting method, sice we could use it to get the information pitest gathers, without having to scrape the xml and html outputs. Pitest automaticaly calls this method for each listener thats registerd (more on that below) and gives them all the mutation results it has gathered (see code).
- runEnd This method gets called at the end of the pitest run. We could use it to safe the gathere information and populate the UI.
To enable Pitest to use custom listeners, one needs to follow the following steps:
- The listeners and thier factorys must have a unique name.
- The factorys must be listed in a file using the qualifiyed name of the factory (pitest example), so in our case it would be
com.amos.pitmutationmate.pitmutationmate.reporting.MyMutationResultListenerFactory
. The file must be namedorg.pitest.mutationtest.MutationResultListenerFactory
. - This file must then be packed into a JAR file
- The JAR file must then be located in
classpath:META-INF/services
- The build script must be adapted so that the JAR file gets added