Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-dev] Main JUnit 5 issues?

Hi Mickael,

> I'd like to invest some hours/days in improving the JUnit 5 story in
> Tycho before we release 2.3.
> What are the main real-life issues with JUnit 5 as of today with Tycho
> 2.3.0-SNAPSHOT?

now that the OpenTest4J classloading issue [1] is fixed, my biggest
issue is that I still need to add some JUni4 declarations, even if I use
JUnit 5 APIs only.

For example, the JUnit 5 How-To [2] recommends placing an Import-Package
on org.junit in my MANIFEST.MF. That is ugly, of course, as I have a
"Dependency" which PDE's "Find Unused Dependency" (rightly) flags as
unused. Also, the "Import Type" Quick Fix on @Test then suggests two
options (org.junit.Test and org.junit.jupiter.api) and it is easy to
pick the wrong import by accident

Alas, if one ignores the How-To and does not use an Import-Package on
org.junit, then one is greeted by an exception when the tests are run:

  org.apache.maven.surefire.util.SurefireReflectionException:
java.lang.ClassNotFoundException:
org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
  	at
org.apache.maven.surefire.util.ReflectionUtils.loadClass(ReflectionUtils.java:249)
  	at
org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:133)
 	at
org.apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.java:265)
  	at
org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:118)
  	at
org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:83)
  	at
org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:116)
  	at
org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication$1.run(AbstractUITestApplication.java:37)
  Caused by: java.lang.ClassNotFoundException:
org.apache.maven.surefire.junitplatform.JUnitPlatformProvider

You can avoid that exception by adding a <dependency> to the
tycho.surefire-plugin in your pom.xml:

  <!-- Needed to avoid CNFE in Surefire; not needed in actual tests -->
  <dependency>
    <artifactId>org.junit</artifactId>
    <type>eclipse-plugin</type>
  </dependency>

But then you are back at square one, having replaced one "unused"
declaration in the manifest with a different one in the POM.

If this issue could be addressed for 2.3.0, that would be awesome.

Best wishes,

Andreas

[1] <https://bugs.eclipse.org/bugs/show_bug.cgi?id=571654>
[2] <https://wiki.eclipse.org/Tycho/How_Tos/JUnit5>

-- 
Dr. Andreas Sewe | sewe@xxxxxxx | +49 152 56342856
CQSE GmbH | Centa-Hafenbraedl-Strasse 59 | 81249 Muenchen | www.cqse.eu
Amtsgericht Muenchen | HRB 177678 | GF: F. Deissenboeck, M. Feilkas

Attachment: signature.asc
Description: OpenPGP digital signature


Back to the top