Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning Eclipse Junit Plugin tests with Junit 4.4 or newer -- why aren't tests detected?
    primarykey
    data
    text
    <p>I need to use JUnit 4.4 (or newer) in a set of eclipse plugin tests, but I've run into the following problem:</p> <p>Tests are not detected when running with the junit 4.4 or 4.5 bundles from springsource (<a href="http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.junit&amp;version=4.4.0" rel="nofollow noreferrer">junit44</a> and <a href="http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.junit&amp;version=4.5.0&amp;searchType=bundlesByName&amp;searchQuery=junit" rel="nofollow noreferrer">junit45</a>). The org.junit4 bundle that can be obtained with eclipse supplies junit 4.3 (as of Ganymead / Eclipse 3.4). The org.junit4 bundle <em>does</em> work in that it identifies and runs the tests, but it is not compatible with the latest versions of JMock, and I need to use a mocking library.</p> <p>Here is a sample test:</p> <pre><code>package testingplugin; import static org.junit.Assert.*; import org.junit.Test; public class ActivatorTest { @Test public final void testDoaddTest() { fail("Not yet implemented"); } } </code></pre> <p>When running this test, I receive the following exception:</p> <pre><code>java.lang.Exception: No runnable methods at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:33) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62) at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:195) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212) </code></pre> <p>However, if I switch the project dependencies from com.springsource.org.junit to org.junit4, then the test runs and fails (as expected).</p> <p>I am running the test as a JUnit Plug-in Test in Eclipse, with the following program arguments:</p> <p>-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}</p> <p>The following plug-ins selected during launch (selected by me, then I used "add required plugins" to get the rest of the dependencies.):</p> <pre><code>Workspace: testingPlugin Target Platform: com.springsource.org.hamcrest.core (1.1.0) com.springsource.org.junit (4.5.0) ....and a bunch of others... (nothing related to testing was auto-selected) </code></pre> <p>Here is my MANIFEST.MF:</p> <pre><code>Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: TestingPlugin Plug-in Bundle-SymbolicName: testingPlugin Bundle-Version: 1.0.0 Bundle-Activator: testingplugin.Activator Import-Package: org.osgi.framework;version="1.3.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: com.springsource.org.junit;bundle-version="4.5.0" </code></pre> <p>Switching the last line to:</p> <pre><code>Require-Bundle: org.junit4;bundle-version="4.3.1" </code></pre> <p>And updating the selected plugins at launch to:</p> <pre><code>Workspace: testingPlugin Target Platform: org.junit4 (4.3.1) ...bunches of auto-selected bundles... (again, nothing else test related) </code></pre> <p>Causes the test to run properly (but with the wrong version of junit).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload