Executing test suite that uses ClasspathSuite filtering

(Ferghal Smyth) #1

I’m am trying to run a single test suite. Defined in the test suite are ClasspathSuite filters with classes inclusions and exclusions. However when I attempt to run this suite from gradle it returns no tests found to run. I can execute the same testsuite from ant and it succeeds.

I believe the issue is because gradle filters the tests on the class path to only have the specified test suite before ClasspathSuite ever gets to filter it. What I would like to do is execute the test suite with the full class path without filtering.

Thanks for the help.

task runTests(type: Test) {
  outputs.upToDateWhen { false }
 testClassesDir = sourceSets.main.output.classesDir
 classpath = sourceSets.test.runtimeClasspath
 include 'MyTestSuite.class'
public class MyTestSuite{

(Peter Niederwieser) #2

The include looks wrong. Try 'include ‘**/MyTestSuite.class’.

(Ferghal Smyth) #3

Sorry that is a typo in the post, it is correct in the code. To be clear the suite executes and the report is generated but no tests are found as the suite doesn’t have any @Test annotates.

(Peter Niederwieser) #4

Gradle’s filtering only determines which test classes (or suites) to execute. The class path will always contain all test classes. Maybe it’s a problem with ‘ClasspathSuite’ and Gradle’s class loader architecture.