I am trying to set up a way to run integration tests with a separate source
set and an integrationTest task.  I am having trouble excluding a base Junit
TestCase class.  I followed a similar example in the User Guide for the
version (0.8) that I am using.

Here are the important pieces related to setting things up: Note: this is
all under a subprojects configuration on the parent build.gradle file in a
multiproject setup.

configurations {
        integrationTestCompile { extendsFrom testCompile }
        integrationTestRuntime { extendsFrom integrationTestCompile,
testRuntime }
}

sourceSets {
        integrationTest {
            java {
                srcDirs = ['integrationTest']
            }
            classesDir = main.classesDir
            compileClasspath = configurations.testCompile
            runtimeClasspath = classes + sourceSets.main.classes +
configurations.integrationTestRuntime
        }
}

task integrationTest(dependsOn: 'compileIntegrationTestJava', type: Test) {
        testClassesDir = sourceSets.integrationTest.classesDir
        classpath = (files(sourceSets.main.classesDir)) +
sourceSets.integrationTest.runtimeClasspath
}

integrationTest.configure {
        useJUnit() {
            fork(forkMode: ForkMode.ONCE, jvmArgs: ["-Xmx256m"])
        }
        exclude '**/*BaseTestCase*'
}

This is the debug output for the above set up when I run the integrationTest
task:

13:03:41.287 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter - Class
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask loaded from parent
loader (parentFirst)
13:03:41.287 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter - fileset: Setup
scanner in dir C:\project\application\war\WEB-INF\classes with patternSet{
includes: [com/application/ApplicationIntegrationBaseTestCase.class,
com/application/instrument/bank/BottleLoadingIntegrationTestCase.class]
excludes: [] }

Notice the excludes isn't set up.

If I change the integrationTest.configure method to be like this:

    integrationTest.configure {
        useJUnit() {
            fork(forkMode: ForkMode.ONCE, jvmArgs: ["-Xmx256m"])
        }
        include '**/*Junk*'
        exclude '**/*BaseTestCase*'
    }

I get this in the debug output:

13:07:58.902 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter - Class
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask loaded from parent
loader (parentFirst)
13:07:58.902 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter - fileset: Setup
scanner in dir C:\project\application\war\WEB-INF\war\WEB-INF\classes with
patternSet{ includes: [**/*Junk*] excludes: [**/*BaseTestCase*] }

Any ideas on how to get this to work.  I want any junit tests excluded from
running when the class name suffix is 'BaseTestCase' but still include all
other '*TestCase' classes.

Reply via email to