Community
Participate
Working Groups
Created attachment 209844 [details] Example project and integration test demonstrating example I've created a simple Tycho POM project with an "eclipse-plugin" and "eclipse-test-plugin". When I run "mvn integration-test", it fails with the attached error log. If I change the Tycho version back to 0.13.0, the test passes.
Created attachment 209845 [details] Log of test error
seems related to Import-Package on org.junit. If I change Import-Package: org.junit;version="[4,5)" to Require-Bundle: org.junit;bundle-version="4.8.1" the test works fine. Alternatively, adding an Import-Package for org.junit.runner also works around the problem. It seems that surefire (at least in the new version 2.10 we use now) implicitly assumes that org.junit.runner.RunWith can be loaded by the test classloader. See [1], line 46. This is not a problem in non-OSGi environemtns but with OSGi classloaders and Import-Package, whether a class can be loaded or not is controlled down to the package level... [1] http://svn.apache.org/viewvc/maven/surefire/tags/surefire-2.10/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4TestChecker.java?view=markup
For now I tend to treat this as a surefire bug. I think that surefire should gracefully handle the case where the RunWith class can't be loaded by the test classloader. Will probably open a bug on surefire and try to provide a patch there.
Thanks for looking at this. Changing from "Import-Package" to "Require-Bundle" works around this issue for me for now. I'll leave this issue open (or to you) as a pointer/note for the Surefire issue.
opened surefire bug http://jira.codehaus.org/browse/SUREFIRE-825 with patch attached.
note to self: watch out for possible regression https://jira.codehaus.org/browse/SUREFIRE-844 when adopting surefire 2.13
There is an easy workaround - reducing priority.
*** Bug 383490 has been marked as a duplicate of this bug. ***
(In reply to comment #5) > opened surefire bug http://jira.codehaus.org/browse/SUREFIRE-825 with patch > attached. patch accepted for surefire 2.13 but not released yet.
maven surefire 2.12.1 was released which includes the fix for https://jira.codehaus.org/browse/SUREFIRE-844.
(In reply to comment #10) > maven surefire 2.12.1 was released which includes the fix for > https://jira.codehaus.org/browse/SUREFIRE-844. sorry, I meant to say http://jira.codehaus.org/browse/SUREFIRE-825 of course
To clarify the status of this issue: * There is a workaround (see comment #2) * The issue is not resolved because we haven't integrated the fixed surefire version yet (see bug 386481)
*** Bug 431593 has been marked as a duplicate of this bug. ***
https://git.eclipse.org/r/#/c/31274/1
http://git.eclipse.org/c/tycho/org.eclipse.tycho.git/commit/?id=652e7a32bcbe7efb4907da4c14e452103816335f
Can a Tycho or Maven Surefire site add some user documentation on how to configure the MANIFEST.MF, pom.xml, and maven-surefire-plugin for projects that consist of multiple eclipse-project and eclipse-test-projects such that @RunWith annotated test cases are executable during command-line maven sessions? I am attempting to track down why a project's OSGi session for surefire junit testing fails to find the expected Parameterized RunWith class and silently chooses the default BlockJUnit4ClassRunner class instead. That leads to this exception: java.lang.Exception: Test class should have exactly one public zero-argument constructor at org.junit.runners.BlockJUnit4ClassRunner.validateZeroArgConstructor(BlockJUnit4ClassRunner.java:144) at org.junit.runners.BlockJUnit4ClassRunner.validateConstructor(BlockJUnit4ClassRunner.java:121) The test plugin properly runs the JUnit test suite from within Eclipse. Documentation on how to use the newer Junit4 annotations within surefire would be helpful. This relates, I believe, to the resolved issue here. I suspect that some explicit statement of Require-Bundle or Import-Package for transitive dependencies is needed within the MANIFEST.MF.
(In reply to comment #16) > The test plugin properly runs the JUnit test suite from within Eclipse. "JUnit Test" or "JUnit Plug-in Test"? > Documentation on how to use the newer Junit4 annotations within surefire would > be helpful. There should be nothing special to consider. If it doesn't work, then you may have found an unknown bug/limitation. If you can reproduce this issue in a minimal, standalone project, please open a new issue.
Within Eclipse, it is the Run As Junit Test variation that works. (I haven't looked into what it takes to get an eclipse-test-plugin that is an OSGi fragment bundle to work within Eclipse. Running as a Junit Test is enough for developer purposes.)
(In reply to Lonnie VanZandt from comment #18) > Within Eclipse, it is the Run As Junit Test variation that works. (I haven't > looked into what it takes to get an eclipse-test-plugin that is an OSGi > fragment bundle to work within Eclipse. Running as a Junit Test is enough > for developer purposes.) this discussion is out of scope for this bug. If you think you found a new bug, open a separate ticket with sample project and steps to reproduce.
(In reply to comment #18) > Within Eclipse, it is the Run As Junit Test variation that works. (I haven't > looked into what it takes to get an eclipse-test-plugin that is an OSGi fragment > bundle to work within Eclipse. Running as a Junit Test is enough for developer > purposes.) So you are not using OSGi when running the tests in Eclipse, and using OSGi when running the tests in Tycho. So your OSGi configuration is incorrect. Please use the regular support channels (e.g. tycho-user@eclipse.org) to get help if needed. Or if you think you have found a bug, do this as proposed in comment #19 and comment #17.
am running tests using tycho 0.22.0 i get the following error [ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.22.0:test (default-test) on project com.xxxxx.abc.datamodel.test: Execution default-test of goal org.eclipse.tycho:tycho-surefire-plugin:0.22.0:test failed. NullPointerException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.22.0:test (default-test) on project com.xxxxx.abc.datamodel: Execution default-test of goal org.eclipse.tycho:tycho-surefire-plugin:0.22.0:test failed. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.eclipse.tycho:tycho-surefire-plugin:0.22.0:test failed. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: java.lang.NullPointerException at org.apache.maven.plugin.surefire.util.ScannerUtil.processIncludesExcludes(ScannerUtil.java:68) at org.apache.maven.plugin.surefire.util.DirectoryScanner.scan(DirectoryScanner.java:76) at org.eclipse.tycho.surefire.TestMojo.scanForTests(TestMojo.java:892) at org.eclipse.tycho.surefire.TestMojo.createSurefireProperties(TestMojo.java:847) at org.eclipse.tycho.surefire.TestMojo.createEclipseInstallation(TestMojo.java:740) at org.eclipse.tycho.surefire.TestMojo.execute(TestMojo.java:621) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) ... 20 more
(In reply to sindhu gururaj from comment #21) > am running tests using tycho 0.22.0 i get the following error this doesn't belong here. please open a new bug with steps to reproduce.