Test Suites
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It's what can be called from the GUI or the textual interface to run all your tests.
Here's an example of my test suite.
You'll see the main that calls the tests first, followed by the suite.
Note that all the individual unit tests are within each class of the suite (i.e. ClasExpMonthsTest.class contains all the individual unit tests for that class) and JUnit uses introspection to find all the tests.
Greg Ostravich - SCPJ2
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Greg Ostravich:
I believe it's the collection of all tests.
It's what can be called from the GUI or the textual interface to run all your tests.
Exactly, but have tried to combine tests from other projects. I think maybe having a testsuite that call all the project test suites. I am still trying to come up with the best design to be able to do it so if anybody has tried to do this please let me know. Thanks...
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Pradeep Bhat:
Do we use junit.textui.TestRunner.run (TestClass.Class) for testing all the test in the TestClass and junit.textui.TestRunner.run (suite()); for testing all the classes?
Yes, the run(Class) method uses the Reflection API to pick up all JUnit test methods from the given class and executes those tests.
However, what the run(TestSuite) method executes depends on what the given TestSuite object returns from its static suite() method. A typical implementation for a TestSuite is to manually construct a list of all children of TestCase in the package (see Greg's example class). It is also a convention to name this kind of TestSuites as "AllTests" similarly to how you name all your TestCases as "_________Test".
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
May I ask how have you implemented this reflection-based test suite? Is it something you've written yourselves?Originally posted by Jeanne Boyarsky:
We have a test suite for each project (that uses reflection to pick up all the tests).
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Well, I personally cut and pasted it from someone else at our company. But basically, it gets all the classes using the test collector for the junit api. It then filters by package name (so you don't run the tests in other projects or jar files if you don't want to.) It also checks to see if the class is abstract and then skips it.
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Do you mean junit.runner.ClassPathTestCollector? Sounds cool.Originally posted by Jeanne Boyarsky:
basically, it gets all the classes using the test collector for the junit api.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
That's the one! I like it because you don't have to remember to add classes to the "master" suite.
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
-
-
Number of slices to send:Optional 'thank-you' note:
-
-

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by lakshmi bvr:
It is a collection of all test cases,test data and test environment including all the modules for entire project, which is maintained by any sofware configuaration tool like VSS.
Again, it depends on the context. A TestSuite in association with JUnit is a collection of Test instances and nothing more.
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
At a client site, Jeff Bay and I paired on a more sophisticated version that covered pattern-based package exclusions (e.g. ignore anything in *.performance) and that read a list of classes to be explicitly ignored. The problem with ignoring tests is just that--often they are forgotten completely!
I look forward to a rewrite of JUnit that takes advantage of the new annotation types in Java 1.5, a la NUnit. I modified JUnit to support an @Ignore tag and can show in the swingui a tab of all test methods marked with @Ignore.
-Jeff-
[ June 02, 2004: Message edited by: Jeff Langr ]
Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Jeff Langr:
I look forward to a rewrite of JUnit that takes advantage of the new annotation types in Java 1.5, a la NUnit. I modified JUnit to support an @Ignore tag and can show in the swingui a tab of all test methods marked with @Ignore.
Actually, Cedric Beust has already wrote one called TestNG and it is compatible with JUnit.
[ June 02, 2004: Message edited by: Chris Mathews ]
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
| Replace the word "snake" with "danger noodle" in all tiny ads. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |











Lasse and Jeanne.