Hello guys.
So far I am in the process of learning Gradle. Now I encountered a weird behavior while using TestNG with additional source set (for integration tests).
Gradle version is 2.14.1
and here is my build.gradle
:
apply plugin: 'eclipse' apply plugin: 'java'
repositories { jcenter() }
sourceSets { test { java.srcDirs = ['src/test/unit/java'] resources.srcDirs = ['src/test/unit/resources'] } integration { java.srcDirs = ['src/test/integration/java'] resources.srcDirs = ['src/test/integration/resources'] compileClasspath += main.output runtimeClasspath += main.output } }
configurations { integrationCompile.extendsFrom testCompile integrationRuntime.extendsFrom testRuntime }
dependencies { testCompile( 'org.testng:testng:6.9.10' //'junit:junit:4.12' ) }
test { useTestNG() //useJUnit() testLogging.showStandardStreams = true }
task integrationTest(type: Test, description: 'Runs the integration tests.', group: 'Verification') { testClassesDir = sourceSets.integration.output.classesDir classpath = sourceSets.integration.runtimeClasspath }
eclipse { classpath { downloadJavadoc = true downloadSources = true } project { natures 'org.eclipse.buildship.core.gradleprojectnature' } }
task refreshEclipse(dependsOn: [ 'eclipse', 'cleanEclipse' ], description: 'Refresh all Eclipse files.')
When using TestNG and executing integrationTest
task:
- all tests from
src/test/unit/java
are executed. - no tests from
src/test/integration/java
are executed.
When using JUnit and executing integrationTest
task:
- all tests from
src/test/unit/java
are executed. - all tests from
src/test/integration/java
are executed.
Is there anything wrong with my script? Or why does Gradle skip additional source set?
Log shows nothing:
gradlew iT --info Starting Build Settings evaluated using settings file 'C:\fenix\workspace\GradleTest\settings.gradle'. Projects loaded. Root project using build file 'C:\fenix\workspace\GradleTest\build.gradle'. Included projects: [root project 'GradleTest'] Evaluating root project 'GradleTest' using build file 'C:\fenix\workspace\GradleTest\build.gradle'. All projects evaluated. Selected primary task 'integrationTest' from project : Tasks to be executed: [task ':compileJava', task ':processResources', task ':classes', task ':compileTestJava', task ':processTestResources', task ':testClasses', task ':compileIntegrationJava', task ':processIntegrationResources', task ':integrationClasses', task ':in tegrationTest'] :compileJava (Thread[main,5,main]) started. :compileJava Skipping task ':compileJava' as it has no source files. :compileJava UP-TO-DATE :compileJava (Thread[main,5,main]) completed. Took 0.019 secs. :processResources (Thread[main,5,main]) started. :processResources file or directory 'C:\fenix\workspace\GradleTest\src\main\resources', not found Skipping task ':processResources' as it has no source files. :processResources UP-TO-DATE :processResources (Thread[main,5,main]) completed. Took 0.001 secs. :classes (Thread[main,5,main]) started. :classes Skipping task ':classes' as it has no actions. :classes UP-TO-DATE :classes (Thread[main,5,main]) completed. Took 0.0 secs. :compileTestJava (Thread[main,5,main]) started. :compileTestJava Executing task ':compileTestJava' (up-to-date check took 0.333 secs) due to: Value of input property 'targetCompatibility' has changed for task ':compileTestJava' Value of input property 'sourceCompatibility' has changed for task ':compileTestJava' All input files are considered out-of-date for incremental task ':compileTestJava'. Compiling with JDK Java compiler API. :compileTestJava (Thread[main,5,main]) completed. Took 0.639 secs. :processTestResources (Thread[main,5,main]) started. :processTestResources file or directory 'C:\fenix\workspace\GradleTest\src\test\unit\resources', not found Skipping task ':processTestResources' as it has no source files. :processTestResources UP-TO-DATE :processTestResources (Thread[main,5,main]) completed. Took 0.002 secs. :testClasses (Thread[main,5,main]) started. :testClasses Skipping task ':testClasses' as it has no actions. :testClasses (Thread[main,5,main]) completed. Took 0.0 secs. :compileIntegrationJava (Thread[main,5,main]) started. :compileIntegrationJava Executing task ':compileIntegrationJava' (up-to-date check took 0.014 secs) due to: Value of input property 'targetCompatibility' has changed for task ':compileIntegrationJava' Value of input property 'sourceCompatibility' has changed for task ':compileIntegrationJava' All input files are considered out-of-date for incremental task ':compileIntegrationJava'. Compiling with JDK Java compiler API. :compileIntegrationJava (Thread[main,5,main]) completed. Took 0.09 secs. :processIntegrationResources (Thread[main,5,main]) started. :processIntegrationResources file or directory 'C:\fenix\workspace\GradleTest\src\test\integration\resources', not found Skipping task ':processIntegrationResources' as it has no source files. :processIntegrationResources UP-TO-DATE :processIntegrationResources (Thread[main,5,main]) completed. Took 0.001 secs. :integrationClasses (Thread[main,5,main]) started. :integrationClasses Skipping task ':integrationClasses' as it has no actions. :integrationClasses (Thread[main,5,main]) completed. Took 0.0 secs. :integrationTest (Thread[main,5,main]) started. :integrationTest Executing task ':integrationTest' (up-to-date check took 0.029 secs) due to: Value of input property 'executable' has changed for task ':integrationTest' Finished generating test XML results (0.003 secs) into: C:\fenix\workspace\GradleTest\build\test-results Generating HTML test report... Finished generating test html results (0.022 secs) into: C:\fenix\workspace\GradleTest\build\reports\tests :integrationTest (Thread[main,5,main]) completed. Took 0.15 secs.
BUILD SUCCESSFUL
Total time: 4.708 secs
Thank you for your help.
Franta