there are two reasons for this exception:

  1. the source code hasn’t been compiled yet.
  2. or on the contrary, the source code has been compiled but it cannot been found by junit.

for reason one, it has no leg to stand. because like many people said: the ‘old’ methods work perfectly. only the new-added methods cannot been identified. then the second reason became the only explanation: junit can not find the freshly compiled classes. having that in mind, i did this: right click the project ->java build path -> edit source item: project_name/src/test/java’s output folder, change the output folder into a ‘specific output folder(path relative to project_name). provide this value: target/test-class. be hold: this is the default test source codes’ output folder defined by maven. it has been overwrote by m2e (or me). that’s why junit cannot find it. so my guess is many people who had run into this lovely exception are most likely dealing with a web project which is managed by maven. am i right?! this also contributed my conclusion that reason one should be excluded -- “old” methods can be found is because they had been automatically compiled when the tomcat was (re)started. into the ‘wrong’ path maybe, but junit found it anyway.

before i had figured this out. i tried many things as advised: update to the latest junit4, back and forth between build path and use as source folder, capital test vs test, etc. nothing happened until i specifically identified the output location for the test source. with all those explanation, my second reason should be re-phrased as this: the new codes had not been timely compiled to the right path! good luck.


i also faced this issue while implementing @runwith(cucumber.class). since this annotation was inside a public class and hence eclipse shows this "no tests found with test runner not found" error.

once i called / placed the test runner annotation before the runner class, the tests showed up nicely.

readers must identify which junit test runner they are using. one can check with @runwith(junit4.class) is outside or inside the runner.class parenthesis {}. if its inside, please place it outside.


if you are trying to setup junit 5 add @runwith(junitplatform.class)

and import org.junit.platform.runner.junitplatform; so that eclipse can recognize the junit 5 test classes as test classes


is your eclipse project maven based? if so, you may need to update the m2eclipse version.

just a quick note: i have a project in eclipse which is maven-based, and generated initially using the "new maven project" wizard in eclipse. i'm using junit 4.5 for the unit tests, and could quite happily run the tests from the command line using maven, and individual tests from eclipse using run as junit test.... however, when i tried to run all of the tests in the project by invoking run as junit test... on the project root node, eclipse complained "no tests found with test runner junit 4". solved by upgrading m2eclipse to the latest stable development build from the m2eclipse update site (specifically, i upgraded from version to version in eclipse galileo).

from here:


this happened to me too. i found that in eclipse i didn't make a new java class file and so that's why it wasn't compiling. try copying your code into a java class file if it's not already there and then compile.


i found out that eclipse seems to only perform junit 3 style tests if your test-class extends from testcase. if you remove the inheritance, the annotations worked for me.

beware that you need to statically import all the required assert* methods like import static org.junit.assert.*.


i also faced the same issue while running junit test. i resolved this by putting the annotation @test just above the main test function.


i had to do a mvn clean on command line then project->clean in eclipse. i renamed the class beforehand then renamed it back but i doubt that helped.


i'm also running eclipse with maven (m2e 1.4). the tests were running with maven, but not with eclipse... even after several application of maven>update project.

my solution was to add some lines in the .classpath generated by m2e. the lines are now sticking.

<classpathentry kind="src" output="target/test-classes" path="src/test/java">
    <attribute name="optional" value="true"/>
    <attribute name="maven.pomderived" value="true"/>


i have this problem from time to time. the thing that resolves the issue most for me is to run the junit test from run configurations... ensuring that junit 4 is set as the test runner.

generally, i see this issue when attempting to run as... junit test from the context menu on the package explorer. if you right click the code for the test you are trying to run and instead of selecting run as... junit test you select run configurations... ensure the project, test class and test runner are set correctly, clicking apply, then run works all the time for me.


i started to work with selenium and eclipse in my job and i was doing my first automated test and i deleted from the code @before, @test, and @after notes and i was having this issue "no tests found with test runner junit4".

my solution it was simply to add again the @before, @test and @after notes and with that my script worked. is important to not delete this from the code.

this is a simple test that uses google to search something:

import java.util.regex.pattern;
import java.util.concurrent.timeunit;

import org.junit.*;

import static org.junit.assert.*;
import static org.hamcrest.corematchers.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.firefoxdriver;

public class testingclass {

    private webdriver driver;
    //creates an instance of the firefoxdriver
    public void setup() throws exception {
        driver = new firefoxdriver();

    //search using keyword through google search
    public void testtestclass2 () throws exception {

    //kill all the webdriver instances
    public void teardown() throws exception {



using scalaide (3.0.4-2.11-20140723-2253-typesafe) i was having a similar problem with the right click scala test class-> run as -> scala junit test context menu.

i tried editting the class(but not for a compile failure), cleaning, closing the project, closing eclipse. none of those worked to restore the context menu for classes that had previously worked well. the test classes don't use the @test annotation and instead use the @runwith(classof[junitrunner]) annotation at the top of the class using scalatest code.

when i tried choosing scala junit test from the run configuration launch editor directly, i received the dialog from the question. footix29's answer was the key for me.

i noticed that even though i had cleaned my project a few times, my classes in the /bin directory hadn't actually been rebuilt in a while.

here's how i got back the context menu, and was able to once again run scala junit tests:

  • manually cleaned the classes by deleting the /bin/<package dir>* via explorer
  • project -> cleaned the project along with a full rebuild

i suspect that a class edit in general is able to clean some saved state of eclipse and get it going again. in my case all of the previously working classes i tried had failed so the manual clean step was just the hammer i needed. however, other tricks that affect eclipse's concept of the class path/build state should also work.

further, i think that this behaviour was triggered in part by attempting to refactor a scala class by renaming it( which the scala eclipse ide sucks at ), where all the cleanup after the initial file change is manual. there were no build errors, but there were also no warnings that i was expecting meaning something was definitely stuck in eclipse's build state info.


my problem was using **


** package org.testng.assert;

you can replace it in libraries of the project (maven) with junit and then need to refactor project.
or add testng eclipse plug-in


i had this issue when my java class name was similar to the test class name. just updated the name of the test class by post fixing it with keywork "test" and it started working

before: java class : acmecontroller test class : acmecontroller

after: java class : acmecontroller test class : acmecontrollertest


in my case the issue was the generics parameters:

public class testclass<t extends serializable> {

removing :

<t extends serializable>

and the option was available again.

i'm using junit4


you might be able to solve this simply by renaming your test class to have a name that ends with test, e.g. thisandthattest


check for updates! eclipse is no doubt fully aware of this problem considering how many workarounds have been presented. there is obviously something systemic involved...something that defies explanation or any sense of consistency. it would have been useful if eclipse would have let the community know what the problem was and how it was fixed.

another recent find for me was to delete any source directories that had no files or the all files were excluded.


if you're sure it used to work and now it's not working anymore, chances are that the java index got corrupted. in the preferences, search for "java index"; it's in "java" and then there's a button "rebuild index" (or use ctrl+3, "find actions", to quickly search for "rebuild java index"). once selected, the next time you try to run the junit test you should see that eclipse is rebuilding the java index and the junit tests should start now.


i ran into this issue because i had a @beforeclass that was not static.

for some reason the error wasn't exposed through my normal junit run configuration.


i tried all the answers above.

in my case my project had both junit4 and junit5 dependencies. i was trying to use junit4 so after making sure i used correct junit4 imports it still did not work.

i finally found the problem. the eclipse junit runner used in the debug configuration was set to junit5. i changed it to junit4 and the tests are now found and executed.


using junit4 and a gradle-based project, none of the earlier suggestions worked in my case. what did work was:

  1. right click your test source folder, and click properties
  2. jump to run/debug settings
  3. select all of the run/debug configurations, and delete them.

my guess is that one of these launch configurations was messing up my junit4 runner. resetting all of the run/debug configurations solved junit4 not finding any tests to run.


i tried all of the suggestions above. only deleting existing test run configurations for that class finally resolved it. eclipse is weird...


ok in my case (using junit5), if i tried to run with


i got error

no tests found in serviceimpltest
is the method annotated with @test?
is the method public?

no tests found in serviceimpltest
is the method annotated with @test?
is the method public?

solution: simply removing @runwith(mockitojunitrunner::class) from top of class worked!


may be your junit launch configuration was for a individual test class, and you somehow changed that config to "run all tests in a source folder, package or project"

but that could trigger the "no tests found with test runner 'junit 4'" error message.

or you did a modification in your test class, removing the @test annotation.
see this wiki page.


what fixed my case was similar to @jamesg's answer: i restarted eclipse, rebuilt the project, and refreshed it; but before i did any of that, i 1st closed the project (right-click project in package explorer -> close project) and then re-opened it. then it worked.

a workaround solution i found before finding that ultimate solution i just described: copy the test class, and run the test class as junit.


check if the folder your tests are in is a source folder. if not - right click and use as source folder.


close and open the project worked for me.


there is another chance, you might have changed junit test from lower version(e.g. junit 3) to junit 4 . is so follow below steps:-

1. right click on class
2. select run as >> "run configurations"
3. check your "test runner" option in new window
4. if it not same as maven change it for example change it as junit 4.


right click the project -> build dependencies -> remove the ones which have been excluded from the build path -> click ok

right click the project -> maven -> update project.

you should be good to go..


you can fix this issue by do as following:

  • right click on the folder named 'test' > build path > use as source folder
  • or you can set classpath same as: <classpathentry kind="src" path="src/test/java"/> . you replace "src/test/java" by your test package

this issue happened because of junit cannot recognize your source code :d


i've had issues with this recently, which seem to be fixed in the latest eclipse.

eclipse-java 4.11.0,2019-03:r -> 4.12.0,2019-06:r


add @test on top of your test.
mouse hover to the annotation.
chose 'add junit 4 library to classpath'


i tried the solution from germán. it worked for all the method from my class but i have a lot of classes in my project.

so i tried removing from build path and then re-adding it. it worked perfectly.

hope it helps.


six years later ... and there are still problems with eclipse and occasionally not finding junits.

in my eclipse mars 2 i discovered that it won't recognise test classes pulled in from git if there are more than 9 or 10 @test annotations in the file. i need to comment out any extra tests, run the test class, then uncomment them and re-run the class. go figure...


when i face this problem i just edit the file and save it... works like charm


my problem was that declaration import org.junit.test; has disappeared (or wasn't added?). after adding it, i had to remove another import declaration (eclipse'll hint you which one) and everything began to work again.


very late but what solved the problem for me was that my test method names all started with captial letters: "public void test". making the t lower case worked.


no testsuits in junit4. use annotations instead or use old junit3 name conventions.




this happened to me as well. i tried restarting eclipse and also prefixed my test-methods with tests. neither worked.

the following step worked: change all your test methods present in @beforeclass and @afterclass to static methods.

i.e. if you have your test method in the below format:

public void testbeforeclass(){

then change it to:

public static void testbeforeclass(){

this worked for me.


i have found out the answer:

i got this error when i executed the test standalone from eclipse (right click on the method and choose to run as junit test),

when i executed the complete class as junit test the test executed correctly with the parameters.


yet another possible solution i'll throw into the ring: i wasn't able to run the test class either from the editor window, nor the package explorer, but right-clicking on the class name in the outline view and selecting run as junit test did work... go figure!


try adding

@test above the method for the test like this

public void testparse()



i was facing the same problem and i debugged it to bad examples on the web and internals of junit. basically don't make your class extend testcase as some examples show for junit 4.x. use some naming convention test or if you want to have an annotation you can use @runwith(junit4.class).

if you need access to assert methods extend assert or use static imports.

if your class extends testcase then even if you use junit 4 runner it will be run as 3. this is because in the initialization code there is detection:

see junit3builder and the lines:

boolean ispre4test(class<?> testclass) {
    return junit.framework.testcase.class.isassignablefrom(testclass);

this returns true and the test for junit4 compatibility won't be tried.


check if your test class extends "testcase". if so, remove that clause. your class does not need to extend from "testcase" class. it's most of the cases i've met.

public class mytestcase extends testcase{
  public void checksomething() {
//result> assertionfailederror: no test found in mytestcase

following testcase should be fine.

public class mytestcase {
  public void checksomething() {
//works fine


in context menu of your 'test' directory choose 'build path' -> 'use as a source folder'. eclipse should see your files as a source files. warning 'no junit tests found' occures because there is no unittests.class files in your 'build' directory


when we get these errors it seems like eclipse is just confused. restart eclipse, refresh the project, clean it, let eclipse rebuild it, and try again. most times that works like a charm.


this just happened to me. rebuilding or restarting eclipse didn't help.

i solved it by renaming one of the test methods to start with "test..." (junit3 style) and then all tests are found. i renamed it back to what it was previously, and it still works.

Related Query

More Query from same tag