Tests are executed twice when included in junit suite

It is annoying that tests are executed twice when included in a test suite.

A normal usecase of test suites is to group multiple tests requiring expensive resources (like database) in a suite. In the suite the expensive resource will be created once and reused for all the test classes. Outside the suite the expensive resource will be created for each test class.

I a test class is part of a suite, then it should be excluded from the normal run.

I did search for solutions to this problem, and the only one I could find (for example this one by Peter Niederwieser: http://stackoverflow.com/a/26341110/1043419 ) was to do a manual exclude in a test configuration

test { exclude 'org.abc.*.class } This is however insufficient as it would require either that we update build.gradle everytime we add a new test, or that we restrict the naming of out test classes, so that we can patternmatch them.

4 Likes