I’m using version 2.4, tested with 2.5-rc-2 as well.
Gradle doesn’t run tests which are annotated with JUnit’s @RunWith(Parameterized.class) (possibly with other runners as well). Here is a test:
$ mkdir test && cd test && gradle init --type java-library
$ ./gradlew clean test --tests Library*
:clean UP-TO-DATE
:compileJava
:processResources UP-TO-DATE
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
BUILD SUCCESSFUL
Now, replace the contents of src/test/java/LibraryTest.java with:
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
@RunWith(Parameterized.class)
public class LibraryTest {
@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ 0, 0 }, { 1, 1 }, { 2, 2 }
});
}
public LibraryTest(int a, int b) {}
@Test public void testSomeLibraryMethod() {
Library classUnderTest = new Library();
assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod());
}
}
and run again:
$ ./gradlew clean test --tests Library*
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [Library*]
But, when no filters are applied, the test is executed fine:
$ ./gradlew clean test
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
BUILD SUCCESSFUL
$ cat build/test-results/TEST-LibraryTest.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="LibraryTest" tests="3" skipped="0" failures="0" errors="0" timestamp="2015-07-03T20:06:28" hostname="Laptop0158" time="0.002">
<properties/>
<testcase name="testSomeLibraryMethod[0]" classname="LibraryTest" time="0.001"/>
<testcase name="testSomeLibraryMethod[1]" classname="LibraryTest" time="0.0"/>
<testcase name="testSomeLibraryMethod[2]" classname="LibraryTest" time="0.0"/>
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
As you can see, the parameterized test method was indeed called 3 times, as expected.
Similarly, I can’t invoke Spock specifications either. I’m not sure whose fault is this one, though, gradle’s or spock’s.