Question

Can anybody explain me the purpose of test suites? I'm using idea+maven (I just started doing with maven) and i have sources like this: my classes

and i clicked to "test" on the lifecycle toolbar of my project, and the result was like this:

------------------------------------------------------- T E S T S ------------------------------------------------------- Running PersonTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec Running PetTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

-i didn't use test suites, so why should i have to use the test suites to test more test classes if it tested my all 2 classes? (in this case i used JUnit 3 - I know there is JUnit 4, but at first i would like to try JUnit 3), thanks.

Was it helpful?

Solution

The suites are there so you can configure any set of classes that you want to run together.

You might want to created different suites for unit tests and integration tests. Maybe you'd like to have tests that run on each save as opposed to tests that run on each build, etc.

JUnit runs tests using a Runner. A Suite is a type of Runner that runs all the classes that are defined to be part of the Suite. Since this is a Java class, you can sub class it and add more functionality to it.

Categories, for instance, are an enhancement of Suite, which allows you to declare tests as belonging to different categories, and then you can run only specific categories (e.g. slow tests vs. fast tests, etc.).

Since Suites are tests by themselves, they can contain other Suites, thus creating a hierarchical structure of tests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top