File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Named TestSuite gives error in JUnit_4.1 used w/Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Named TestSuite gives error in JUnit_4.1 used w/Eclipse" Watch "Named TestSuite gives error in JUnit_4.1 used w/Eclipse" New topic
Author

Named TestSuite gives error in JUnit_4.1 used w/Eclipse

Rick Shroff
Greenhorn

Joined: Mar 06, 2008
Posts: 10
Hi All,
I created a TestSuite using the Eclipse wizard and JUnit4_4.1. Works fine with the default name "AllTests". But if change the name to something else, gives error - "java.lang.Exception: No runnable methods".
If I use JUnit_3.8.1 and Eclipse; everything works fine even if I can change the name of the TestSuite. Looks like something to do with JUnit4_4.1 version. The jar file is called junit-4.1.jar and Eclipse version is 3.2.0

Below are the error traces and the code used. Please advise-

Test


TestSuite


Error Message and Trace



Cheers,<br />Rick<br />SCJP
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Eclipse has two different runners for JUnit 3 and JUnit 4 tests. Your test suite is JUnit 3 - style (see http://radio.javaranch.com/lasse/2006/07/27/1154024535662.html for how to do it JUnit 4 - style).

When you run the test from Eclipse, make sure that the launch configuration is configured for the correct version of JUnit. If you don't, you will get exactly the error message you got.

I think there is also a global setting for what Eclipse will use as default.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Rick Shroff
Greenhorn

Joined: Mar 06, 2008
Posts: 10
Hi Ilja,


Eclipse has two different runners for JUnit 3 and JUnit 4 tests. Your test suite is JUnit 3 - style (see http://radio.javaranch.com/lasse/2006/07/27/1154024535662.html for how to do it JUnit 4 - style).

I went to the above link ans was able to successfully run the TestSuite. Thanks a lot. I think this URL link is one of the very rare places where this is documented.



When you run the test from Eclipse, make sure that the launch configuration is configured for the correct version of JUnit. If you don't, you will get exactly the error message you got.

I think there is also a global setting for what Eclipse will use as default

For changing Launch Configuration, I navigated to Windows--->Preferences --->Launcing --> Launch Configurations. But did not change anything. Did not know how to do it.

Any way it seems to be picking up the JUnit version correctly from the Libraries specified in the JavaBuild Path.

Thanks Again!!
 
jQuery in Action, 2nd edition
 
subject: Named TestSuite gives error in JUnit_4.1 used w/Eclipse
 
Similar Threads
query a database table using a foreign key ( where) using Hibernate.
DBCP jar files
Junit error
Problem creating a dummy web service w/ WS-RM
Junit with Testsuit error