This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Testing and the fly likes Add testSuites to other test suites? 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 "Add testSuites to other test suites?" Watch "Add testSuites to other test suites?" New topic
Author

Add testSuites to other test suites?

Ryan Day
Ranch Hand

Joined: Apr 03, 2006
Posts: 87
I'm getting an error when I try to create a top-level Junit test suite that will call multiple other test suites.

I am trying to create a JUnit test suite "AllTests" that contains all of the TestSuites in other packages.

The lower-level AllTests looks like this (with package and class names changed to samples):



Here is the higher level test suite I created:



The low level test suites run fine, but when I try to run the higher level test suite, I get the following error:



junit.framework.AssertionFailedError: No tests found in com.sample.business.AllTests


SCJP, SCWCD
Rodrigo Lopes
Ranch Hand

Joined: Feb 29, 2008
Posts: 119
One guess:

com.sample.business.AllTests has to extend TestSuite
[ June 05, 2008: Message edited by: Rodrigo Lopes ]
Ryan Day
Ranch Hand

Joined: Apr 03, 2006
Posts: 87
>>One guess: com.sample.business.AllTests has to extend TestSuite

Tried this. Still no luck.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
In the higher level suite, you need to add "AllTests.suite()" and not "AllTests.class".


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Ryan Day
Ranch Hand

Joined: Apr 03, 2006
Posts: 87
Thank you both for your help. Here is the working "suite of suites":


[ June 06, 2008: Message edited by: Ryan Day ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Add testSuites to other test suites?
 
Similar Threads
setUp and teardown not working
Trouble using addTestSuite() vs. addTest()
Could not invoke suite() method !!
Junit with Testsuit error
Junit and Selenium - Passing objects between test cases and test suites