Closed jscancella closed 4 years ago
Thanks for the idea. JUnit 5 becomes more and more popular.
I definitely didh't like the idea to release a different plugin variant to just support JUnit 5. However, even nicer idea sprang to my mind :-).
I added the new junit5PluginVersion
configuration property. If set it will add dependency to org.pitest:pitest-junit5-plugin
in requested version and also set testPlugin
to junit5
(unless set explicitly).
plugins {
id 'java'
id 'info.solidsoft.pitest' version '1.4.7-SNAPSHOT'
}
pitest {
//it adds dependency to org.pitest:pitest-junit5-plugin and also sets "testPlugin" to "junit5"
junit5PluginVersion = '0.12'
}
You could give the snapshot version a try - unfortunately, with plugins {}
it is more challenging :-/
Add to your settings.gradle
:
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == 'info.solidsoft') {
useModule('info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.4.7-SNAPSHOT')
}
}
}
repositories {
// mavenLocal() //this is needed only for working with locally installed snapshot
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
mavenCentral()
}
}
It took some wrangling (those changes to settings.gradle
messed up a bunch of other things), but I was finally able to run 'info.solidsoft.pitest' version '1.4.7-SNAPSHOT'
If you released this as version 1.4.7, would I still need to have the configuration in the settings.gradle
file?
Not at all. It's just to play with the SNAPSHOT version of the plugin using the plugins {}
syntax. Gradle doesn't make it easy :-(.
With a regular version junit5PluginVersion = '0.12'
should be the only required change.
sounds great to me! I look forward to when you release it!
Great. I plan to do that once #155 is fixed.
Available in just released 1.4.7.
@szpak how can I add other pitest plugins now, like pitest-mutation-testing-elements-plugin?
As usual, mixing the plugin {}
and buildscript {}
syntax. JUnit 5 is very popular (and it is not built in into PIT itself), so there is a dedicated way. I don't plan to add that configuration for every plugin.
See this section in my blog post for more details: https://blog.solidsoft.pl/2020/02/27/pit-junit-5-and-gradle-with-just-one-extra-line-of-configuration/#modern-approach-with-plugins-br-with-older-gradle-pitest-plugin
Currently in my build script I have to add
so that pitest will support my junit5 tests. This is very ugly since everything else I can just define using the more modern
plugins
configuration. Is there any chance you could release a different plugin that already includes the junit5 dependency so I can remove this code from my build.gradle file?