I just figured it out. After re-reading the Test Task documentation I
realized the search criteria for the test classes to run was based on
classes that extend the TestCase class. I didn't expect that. I would
think it is common that people would create base test cases that aren't run
as part of the "suite". Are there more people that turn that feature off
than leave it on?
This is what works for me:
integrationTest.configure {
useJUnit() {
fork(forkMode: ForkMode.ONCE, jvmArgs: ["-Xmx256m"])
}
scanForTestClasses = false
include '**/*TestCase*'
exclude '**/*BaseTestCase*'
}
jashatton wrote:
>
> 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.
>
>
--
View this message in context:
http://old.nabble.com/Setting-up-a-Integration-Test-source-set-and-new-integrationTestTask--based-on-0.8-User-Guide-tp28046120p28046334.html
Sent from the gradle-user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email