Eclipse does not see my new unit test

I use eclipse to run tests in one junit (4) test class. Tests in the class all work fine. Then I add an extra test and run the class using a test that runs in ecplise again. Only old tests are performed. A new test is not observed in eclipse. There is no error or anything else, it looks like eclipse is looking at the old version of the test.

If I run tests using maven, everything works fine. In addition, after running tests in maven, ecplipse can correctly see and run a new test.

Any idea what is going on? Any ideas on how to get an ecplipse test drive to see my new test cases?

+12
eclipse junit
Apr 6 '10 at 16:20
source share
9 answers

I had the same problem. I solved this by doing the following:

  • Going to the project -> Properties -> Java Build Path
    For the source folder src/test/java output folder was set to "Default output folder"
  • Setting this to a typical Maven target/test-classes directory in your Maven structure

After that, Maven and Eclipse were in sync (unlike Eclipse, who happily ran the older version of the tests, starting with any last Maven compilation).

+10
Mar 29 2018-12-12T00:
source share

Perhaps you just need to create a new launch configuration. Eclipse “remembers” the last Run configuration used and simply repeats it unless otherwise specified. To make sure that you have a new launch setting, you can click the test case in the package explorer and select “Run as | Junit test. The next time you click the game, it will be a“ remembered ”launch configuration, etc.

+1
Feb 11 '11 at 10:58
source share

Maybe src / test is not in the Java build path.

Kepler's solution:

Project → Build Path → Configure Build Path → Source → Add Folder

Then check the box corresponding to the test in the src section

+1
Dec 24 '13 at 16:26
source share

Perhaps this is due to the use of Maven for assembly (Maven is usually embedded in the target folder), but Eclipse uses a different assembly for its own build process. The easiest way is to enter the target folder in the Eclipse project (or the Bundle when using OSGi) and delete the conflicting subfolders / class files from this directory; for me, this is my "target" folder. Then run Eclipse to recover, and everything will be fine.

Technically, and, alternatively, you could just knock down the entire assembly / target folder if you want, and let Eclipse rebuild everything.

+1
Oct 13 '15 at 4:33
source share

In response to the answer provided by Ryan Dow, I found that the default output folder can only be installed in one folder for all source folders on the build path. Therefore, if I changed the output folder to target / test classes, my src / main / java also output classes there. You may have written this answer for another old version of eclipse, but with the release of Mars.2 we can only have one default output folder for all source folders.

The best solution I have found so far for this problem is to simply include the target / test classes as a class folder by going to Project -> Properties -> Java Build Path -> Libraries -> Add Class folder.

+1
Apr 03 '16 at 21:16
source share

It seems your project has not been recompiled. Either check the menu: Project / Build Automatically or do it manually, as Boris Pavloch commented.

0
Apr 10 '10 at 19:41
source share

This seems like the same problem that junit is not using the latest file

The problem is that Eclipse puts the compiled tests in the wrong folder, which can be solved by manually specifying where they should be.

0
Jun 15 '11 at 12:01
source share

Add a “test” in front of your test classes if you no longer have the @Test annotation that is not always fetched from the Eclipse Junit Test environment.

0
May 16 '17 at 16:44
source share

This is how I fixed my problem ...

  1. right-click the project and go to Run As → Run Settings ...
  2. select JUnit → [project name] in the popup that appears. (this configuration [project-name] was created for me by eclipse but if it is not there, you can right-click JUnit -> New and create it)
  3. Go Classpath tab
  4. Highlight User Records and click the Advanced button ... button
  5. .In the pop-up Advanced menu that appears, select Add Folders and click OK
  6. . in the pop-up Folder that appears, scroll to your project, open target , select test-classes and click OK
  7. . Repeat steps 4-6 for the [project-name] / target / classes directory and any other directory needed in your classpath (for example, the properties files used in your tests, etc.)

Note : it is assumed that the default project output folder for tests is target / test-classes, if it is not, change it accordingly. Also, make sure you have the correct version of JUnit selected in the “JUnit Launch Configuration” section, and the src / test / java directory is the source folder for your project, etc., as others have mentioned.

0
Aug 08 '19 at 15:36
source share



All Articles