Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

not all junit tests are running in eclipse

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?

like image 353
oshai Avatar asked May 13 '13 07:05

oshai


People also ask

How do you run all tests in JUnit?

Method 1: Right-click on the class file in the Script view. Select Run As -> JUnit Test. The class file executes.

Why is JUnit ignoring tests?

Sometimes you may require not to execute a method/code or Test Case because coding is not done fully. For that particular test, JUnit provides @Ignore annotation to skip the test. Ignore all test methods using @Ignore annotation.

Why Eclipse is not showing as JUnit?

That kind of J icon filled to a "bubble" means that Eclipse doesn't recognize your project as a Java project, and therefore doesn't provide Java options such as Run as JUnit. Try reimporting the project as a Java Project. Save this answer.


2 Answers

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.

like image 105
MTen Avatar answered Sep 19 '22 18:09

MTen


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

like image 36
Gondlar Avatar answered Sep 23 '22 18:09

Gondlar