not all junit tests are running in eclipse

13,426

Solution 1

Ran into the same problem, my error was that I wrote: public void myMethodName(){ //assertions }

instead of: public void testMyMethodName() { //assertions }

the test before the MyMethodName is important.

Solution 2

It's a bit late, but in case anyone finds this via a search engine:

If a Test is run multiple times the results provided by JUnit are indistinguishable for those Tests and thus the results are only displayed for one run. See also the following Eclipse bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=172256

Solution 3

In jUnit 4, a test case needs to have @Test annotation. The test case can be set to ignore with @Ignore annotation. The whole test class can also be set to ignore by placing the @Ignore annotation right above the class declaration. Note: In jUnit 4 , there is no need to extend Testcase class as in jUnit 3. Everything is in annotation.

I have no idea about jUnit 3 since I use only 4.

Solution 4

Check if you are excluding tests from run by attributes and check under Run > Run Configurations if your JUnit configuration are excluding any tests.

Solution 5

I had a similar problem. For some reason, the "Run As -> jUnit Test" was always skiping the first test package. I was on an older version of Eclipse and SpringSource.

I moved back to Juno - Version: 4.2.1 and all my test run when I perform: "Run As -> jUnit Test. "

Share:
13,426

Related videos on Youtube

oshai
Author by

oshai

Kotlin & Java developer, new technologies enthusiast. likes beautiful code when I see it.

Updated on September 16, 2022

Comments

  • oshai
    oshai over 1 year

    I have a java project in eclipse, when I press the project right click -> run as junit some tests do not run. I attached a picture, see YamiMailSenderTest for example.
    When I try to run the tests directly they are running.
    I am using eclipse 3.7.2.

    enter image description here

    and expanded view:

    enter image description here

    Any idea?

    • Duncan Jones
      Duncan Jones almost 11 years
      If you expand one of trees that were not executed, what do you see?
  • IqbalHamid
    IqbalHamid almost 6 years
    @If you could explain why JUnit tests must be prefixed with 'test', your answer would merit an upvote.