Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JUnit 5 #113

Merged
merged 5 commits into from
Mar 1, 2020
Merged

Support JUnit 5 #113

merged 5 commits into from
Mar 1, 2020

Conversation

echebbi
Copy link
Collaborator

@echebbi echebbi commented Mar 1, 2020

Closes #73.

Rely on the pitest-junit5-plugin Maven plugin to discover JUnit 5 tests. Its JARs are wrapped as an Eclipse bundle and dynamically added to Pitest's classpath when JUnit 5 is detected in project's classpath.

Sadly, some exceptions are shown in the console when running JUnit 5 tests but I didn't manage to solve them; actually I suspect that they depend on the version of JUnit 5 installed in Eclipse IDE.

Excerpt of an output produced by Pitest
 java.lang.NoClassDefFoundError: org/junit/platform/engine/support/filter/ExclusionReasonConsumingFilter
   at org.junit.vintage.engine.discovery.VintageDiscoverer.createTestClassPredicate(VintageDiscoverer.java:83)
   at org.junit.vintage.engine.discovery.VintageDiscoverer.collectTestClasses(VintageDiscoverer.java:61)
   at org.junit.vintage.engistderr  : ne.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:51)
   at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:65)
   at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:130)
   at ostderr  : rg.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:117)
   at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
   at org.pitest.junit5.JUnit5TestUnitFinder.findTestUnits(JUnit5TestUnitFinder.javstderr  : a:79)
   at org.pitest.testapi.execute.FindTestUnits.findTestUnits(FindTestUnits.java:57)
   at org.pitest.testapi.execute.FindTestUnits.getTestUnits(FindTestUnits.java:40)
   at org.pitest.testapi.execute.FindTestUnits.findTestUnitsForAllSuppliedClasses(Findstderr  : TestUnits.java:29)
   at org.pitest.mutationtest.execute.MutationTestMinion.findTestsForTestClasses(MutationTestMinion.java:154)
   at org.pitest.mutationtest.execute.MutationTestMinion.run(MutationTestMinion.java:94)
   at org.pitest.mutationtest.execute.Mutstderr  : ationTestMinion.main(MutationTestMinion.java:137)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.support.filter.ExclusionReasonConsumingFilter
   at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
   at java.lang.ClassLoadstderr  : er.loadClass(ClassLoader.java:424)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
   ... 14 more

@echebbi echebbi added an: enhancement 📈 Improve something for: pitest 🐦 Related to PIT integration impacts: ux 😄 Related to the user experience labels Mar 1, 2020
@echebbi echebbi self-assigned this Mar 1, 2020
@echebbi echebbi added the is: untested ❗ Provide untested features label Mar 1, 2020
@codecov
Copy link

codecov bot commented Mar 1, 2020

Codecov Report

Merging #113 into master will decrease coverage by 0.47%.
The diff coverage is 77.77%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #113      +/-   ##
============================================
- Coverage     84.86%   84.39%   -0.48%     
+ Complexity      298      296       -2     
============================================
  Files            45       45              
  Lines          1242     1243       +1     
  Branches         88       89       +1     
============================================
- Hits           1054     1049       -5     
- Misses          127      132       +5     
- Partials         61       62       +1
Impacted Files Coverage Δ Complexity Δ
...ner/src/org/pitest/pitclipse/runner/PitRunner.java 51.28% <ø> (+1.28%) 6 <0> (ø) ⬇️
...org/pitest/pitclipse/runner/io/SocketProvider.java 73.17% <ø> (-1.25%) 10 <0> (ø)
...c/org/pitest/pitclipse/runner/PitCliArguments.java 94.38% <0%> (-2.17%) 25 <0> (ø)
...er/src/org/pitest/pitclipse/runner/PitOptions.java 90.24% <100%> (-3.78%) 17 <1> (ø)
...er/src/org/pitest/pitclipse/runner/PitRequest.java 94.11% <0%> (-5.89%) 5% <0%> (-1%)
...er/src/org/pitest/pitclipse/runner/PitResults.java 83.87% <0%> (-3.23%) 5% <0%> (-1%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46ca555...1df64f7. Read the comment docs.

@echebbi
Copy link
Collaborator Author

echebbi commented Mar 1, 2020

Actually, Pitclipse cannot run JUnit 5 tests when it is installed from an update site:

org.pitest.util.PitError: Could not load requested test plugin junit5

Hopefully it will just be a matter of adding the META-INF/services/org.pitest.testapi.TestPluginFactory file to org.pitest.pitest-junit5-plugin.

@echebbi
Copy link
Collaborator Author

echebbi commented Mar 1, 2020

Actually I just missed the Eclipse-BundleShape: dir line in pitest-junit5-plugin's MANIFEST.MF file.

Moreover I observed that no exception was shown in the console when testing JUnit 5 on Eclipse Oxygen which confirms my preceding hypothesis.

Because:
 - older versions of Eclipse IDE do not support JUnit 5,
   making hard to test whether Pitclipse supports JUnit 5 test

Breaking change:
 - drop support for Eclipse Mars, Eclipse Neon
Details:
 - wrap the pitest-junit5-plugin Maven plugin as an Eclipse bundle
 - this plugin allows Pitest to detect JUnit 5 tests; it is dynamically added to Pitest's classpath when JUnit 5 is detected in project's classpath
Because:
 - they are shown in the console during PIT execution but provide no value
Because:
 - I just faced issues while changing project's version due to Maven using the tycho-versions-plugin 1.3.0
@sonarcloud
Copy link

sonarcloud bot commented Mar 1, 2020

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@echebbi echebbi merged commit 1402a5e into master Mar 1, 2020
@echebbi echebbi deleted the 73-support-junit5 branch March 1, 2020 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
an: enhancement 📈 Improve something for: pitest 🐦 Related to PIT integration impacts: ux 😄 Related to the user experience is: untested ❗ Provide untested features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pitclipse does not work with Junit 5
1 participant