简体   繁体   中英

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.

在此输入图像描述

and expanded view:

在此输入图像描述

Any idea?

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.

检查是否从属性运行中排除测试 ,如果JUnit配置排除任何测试,请在Run > Run Configurations下检查。

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.

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

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. "

I had the same problem. Eclipse would only recognize and run 5 out of my 9 tests. After much troubleshooting I found this trick to convince Eclipse to recognize the remaining tests: just open each file, hit space and then backspace to mark it as changed, and save it. Then, Eclipse will recognize it as a test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM