Running Eclipse Junit Plugin tests with Junit 4.4 or newer -- why aren't tests detected?

I need to use JUnit 4.4 (or newer) in a set of eclipse plugin tests, but I've run into the following problem:

Tests are not detected when running with the junit 4.4 or 4.5 bundles from springsource (junit44 and junit45). The org.junit4 bundle that can be obtained with eclipse supplies junit 4.3 (as of Ganymead / Eclipse 3.4). The org.junit4 bundle does 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.

Here is a sample test:

package testingplugin;

import static org.junit.Assert.*;
import org.junit.Test;

public class ActivatorTest {
   public final void testDoaddTest() {
      fail("Not yet implemented");

When running this test, I receive the following exception:

java.lang.Exception: No runnable methods
    at org.junit.internal.runners.TestClassRunner$1.runUnprotected(
    at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
    at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at org.eclipse.equinox.launcher.Main.invokeFramework(
    at org.eclipse.equinox.launcher.Main.basicRun(
    at org.eclipse.equinox.launcher.Main.main(

However, if I switch the project dependencies from to org.junit4, then the test runs and fails (as expected).

I am running the test as a JUnit Plug-in Test in Eclipse, with the following program arguments:

-os ${target.os} -ws ${} -arch ${target.arch} -nl ${}

The following plug-ins selected during launch (selected by me, then I used "add required plugins" to get the rest of the dependencies.):

Target Platform: (1.1.0) (4.5.0)
   ....and a bunch of others... (nothing related to testing was auto-selected)

Here is my MANIFEST.MF:

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

Switching the last line to:

Require-Bundle: org.junit4;bundle-version="4.3.1"

And updating the selected plugins at launch to:

Target Platform:
   org.junit4 (4.3.1)
   ...bunches of auto-selected bundles... (again, nothing else test related)

Causes the test to run properly (but with the wrong version of junit).

Asked by: Thomas598 | Posted: 28-01-2022

Answer 1

In my experience this happens if the plugin which contains the plugin tests does not depend on junit. After adding the junit 4.4 dependency to my MANIFEST.MF file the error went away and all tests were executed. The junit dependency should be optional because the plugin usually only needs it for the test code.

Answered by: Ada386 | Posted: 01-03-2022

Answer 2

I cannot test this right now as I don't have an Eclipse 3.4 installation handy, but I've run across a similar problem a while ago in (I think) IntelliJ IDEA 7.0.x, and a workaround was to explicitly specify a test runner.

With JUnit 4.5:

import org.junit.runners.JUnit4;

public class ActivatorTest {

If this does not work you may have more success with org.junit.runners.BlockJUnit4ClassRunner

For JUnit 4.4 I would try org.junit.internal.runners.JUnit4ClassRunner

EDIT : not too sure about the com.springsource. part as I don't use Springsource. From your question it seems that springsource repackages JUnit under but you use just org.junit in your code so I'll stick with that.

Answered by: Michael578 | Posted: 01-03-2022

Answer 3

I'm wondering whether you might need to import the @Test tag from and not from org.junit.


Answered by: Agata455 | Posted: 01-03-2022

Answer 4

I had some similar sounding problems with jMock, JUnit & Eclipse recently, although admittedly not with plugin tests.

I'm not sure if it's relevant, but I got it all working with the following versions :-

  • jmock-2.5.1.jar
  • hamcrest-core-1.1.jar
  • hamcrest-library-1.1.jar
  • jmock-junit4-2.5.1.jar

I also found I had to use the JMock test runner like this :-

  import org.junit.Test;
  import org.junit.runner.RunWith;

  import org.jmock.Mockery;
  import org.jmock.Expectations;
  import org.jmock.integration.junit4.JUnit4Mockery;
  import org.jmock.integration.junit4.JMock;

  public class PublisherTest {

    Mockery context = new JUnit4Mockery();

    public void oneSubscriberReceivesAMessage() {

Answered by: Rafael965 | Posted: 01-03-2022

Answer 5

I don't know which version of JUnit it was, but to succesfully find test the test methods name must start with the word "test".

In newer version you can simply mark test with @Test, for me it works in this combination:

import static junit.framework.Assert.*;
    public void testDummy() throws Exception

Answered by: Tara365 | Posted: 01-03-2022

Answer 6

Maybe your JUnit bundle is missing an entry in the MANIFEST.MF:

Dynamic-Import-Package: *

This is mandatory to load classes from other bundles.


Answered by: Kellan200 | Posted: 01-03-2022

Answer 7

ActivatorTest needs to extend TestCase

Answered by: Emma274 | Posted: 01-03-2022

Answer 8

@RunWith(Suite.class) @SuiteClasses( { UserServiceTest.class,ABCServiceTest.class })

public class AllTestSuite {

public static Test suite() {

     return new JUnit4TestAdapter(AllTestSuite .class);


Answered by: Catherine245 | Posted: 01-03-2022

Answer 9

I think the spring testing framework is not compatible with junit 4.4+

Answered by: Blake298 | Posted: 01-03-2022

Similar questions

java - User not detected as being logged in until '/login' url is hit

I'm using the Play! Framwork with the standard Secure module. What i am seeing, is when a user logs in, and checks remember me, everything works fine. If they close the browser window, re-open and go back to the page, the user is not logged in anymore, but if they goto the default login url '/login', it automatically logs them in and redirects back to the home page with the user correctly being show as logged in. W...

java - Detected request JSP

I'm currently writing a JSP-application with webservices. The problem is: I should detect the clicked link so I can redirect to the specific jsp page. On this JSP-page there will be a request to the web service which will be also done by the same servlet. (Or is it easier to create two different servlets?) Does anyone have a solution/suggestion to detect the clicked link in JSP? Or do I have to store this in the se...

java - Spring beans are not detected in JAX-WS service

I am trying to consume a JAX-WS CXF webservice written by me. I always get nullPointerException for spring autowired annotated beans. However, everything works fine within serverSide over web, but accessing beans through JAX-WS CXF webservice. I have tried by extending SpringBeanAutowiringSupport, but still no luck. How can I do this. regards, Aqif

java - jar files are not being detected

I have a class called in default package. it needs a jar called example.jar. the structure of example.jar is -> degault package-> snmp.class. now makes use of this snmp.class. So now it works fine because and snmp.class are in default package. But i...

java - Child nodes are not getting detected

Here is a XML: <mesh> <triangles material="face" count="990"> <input semantic="VERTEX" source="#boyShape-skin-vertices" offset="0"/> <input semantic="NORMAL" source="#boyShape-skin-normals" offset="1"/> <input semantic="TEXCOORD" source="#boyShape-skin-map-channel1" offset="2" set="1"/> <p>45 56 44 61 57 45 58 58 46 58 58 46 65...

java - End element isn't detected by Stax

I'm reading a XML file same as below: <ts> <tr comment="" label="tr1"> <node order="1" label="" /> </tr> </ts> And I expected the below code prints out three e on screen: XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader sr = factory.createXMLStreamReader(new FileReader("test.xml")); while (s...

java - Control key is not getting detected

This key event is not working. The same code is working for, VK_SPACE Its not working for control private void jTextArea1KeyPressed(java.awt.event.KeyEvent evt) { if ((evt.getKeyChar() == KeyEvent.VK_CONTROL)) { System.out.println("CONTROL IS PRESSED"); } }

Java socket closed not detected

I've written a little Server/Client Application. Here is the code try { OutputStream os = clientSocket.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); System.out.println("clientsocketstatus connected: " + clientSocket.isConnected()); System.out.println("clientsocketstatus closed: " + clientSocket.isClosed()); oos.writeObject(keepAliveNW); } catch(Exception e) ...

java - Tomcat 6 Servlet not detected

Ok, This should be basic, and I have used servlets many times before via eclipse and weblogic and no problems. However with Tomcat 6 I am having issue with Servlet mapping. web.xml: <web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="" ...

java - Detected JDK Version: 1.6.0-24 is not in the allowed range 1.7

When I ran the command mvn clean package I am getting error: Detected JDK Version: 1.6.0-24 is not in the allowed range 1.7. How to fix the above error? I tried to check jdk version isntalled and got this java version "1.7.0_03" Java(TM) SE Runtime Environment (build 1.7.0_03-b04) Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mo...

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)