views:

869

answers:

5

Is it possible to run JUnit tests for multiple packages at the same time without manually creating test suites.

For example if I have the hierarchy:

code.branchone
code.branchone.aaa
code.branchone.bbb
code.branchtwo
code.branchtwo.aaa
code.branchtwo.bbb

Is it possible to:

  1. Run all tests in code.branchone and in descendent packages
  2. Run all tests in say code.branchone.aaa and code.branchtwo.bbb

The problem I see with manually creating test suites is that when new tests come along you may forget to add them.

A: 

I beleieve that you can add all your test packages to a single directory. If you right click on this directory, then you should find the "run as -> JUnit test" option available. This will run all tests contained in the directory and will catch anything you've added. Any new tests get put in there with the rest of them and whatever package name you have it doesn't matter. Hope that helps

chillysapien
+1  A: 

Sure, right-click on the packages you want, and select Run As... JUnit Test

Phil
+1  A: 

In Eclipse, on your debug/run configurations you have the following options:

  1. Run a single test
  2. Run all tests in the selected project, package or source folder

I think the second option is your friend in this case.

bruno conde
but it doesn't let you run tests from different packages
Eishay Smith
A: 

To 2.: Set up a TestSuite. You can pack different unit tests in one file.

furtelwart
A: 

I'm sure u can tweak this a bit. Make a Collection of the CLASSES_DIR property and loop over it in the findClasses method. (junit4)

http://burtbeckwith.com/blog/?p=52

Jurgen H