Test single executes test twice if test file part of a suite


(Normand Fortier) #1

If I run a test on a single file from the command line using the “–tests” argument, each test method is executed twice if the test file is referred to within a test suite:
@RunWith(Suite.class) @Suite.SuiteClasses( { [test file name].class }) public class SuiteName {}

If I comment out the test file name in the suite and then run the single test, test methods are executed once (correct behaviour).

However this does not happen if I run the test from the command line using the old “-Dtest.single” property, ie:
$ gradle -Dtest.single=[test file name] test

For instance, a test file with 17 tests including 1 failing test:
with “–tests”: "34 tests completed, 2 failed"
with "-Dtest.single: “17 tests completed, 1 failed”

This is related to this post, but I am starting from the opposite direction: I need to run certain tests individually while developing. The solution offered in the other post implies one would have to exclude (in the build file) each test that is present in a suite, a rather cumbersome procedure; even by doing that, running the single test stilll executes each method twice.

This is with Gradle 3.2.1 on Archlinux.