Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up the unit and integration tests into two groups. Allows
execution of unit tests once, and integration tests can be executed per dialect.
- Loading branch information
1 parent
59231c0
commit 47a9ed0
Showing
74 changed files
with
152 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
sourceSets { | ||
integrationTest { | ||
// java.srcDir 'src/integrationTest/java' | ||
compileClasspath += sourceSets.main.output | ||
compileClasspath += sourceSets.test.output | ||
// resources.srcDir 'src/integrationTest/resources' | ||
runtimeClasspath += sourceSets.main.output | ||
runtimeClasspath += sourceSets.test.output | ||
} | ||
} | ||
|
||
configurations { | ||
integrationTestImplementation.extendsFrom testImplementation | ||
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly | ||
} | ||
|
||
dependencies { | ||
// Provides, at compile-time, the classes produced by the main and test SourceSets, | ||
// allowing the integration tests to access the production code in main | ||
// and allowing them to reuse any unit test helper methods in test. | ||
integrationTestImplementation sourceSets.main.output | ||
integrationTestImplementation sourceSets.test.output | ||
|
||
// Provides, at compile-time, the dependencies that both | ||
// main and test require in order to successfully compile. | ||
integrationTestImplementation configurations.implementation | ||
integrationTestImplementation configurations.testImplementation | ||
|
||
// Provides, at run-time, the dependencies that both | ||
// main and test require to run. | ||
integrationTestRuntimeOnly configurations.runtimeOnly | ||
integrationTestRuntimeOnly configurations.testRuntimeOnly | ||
} | ||
|
||
task integrationTest(type: Test) { | ||
// The group and description are useful to define | ||
// as they will be shown to anyone who runs gradle tasks, | ||
// which provides a detailed list of all runnable tasks | ||
// within the project. | ||
|
||
group = LifecycleBasePlugin.VERIFICATION_GROUP | ||
description = 'Runs the integration tests.' | ||
|
||
// Integration tests are often memory intensive and | ||
// could use an increase in the JVM’s maximum heap size. | ||
|
||
// maxHeapSize = '1024m' | ||
|
||
// The task requires us to define where both our classes and classpath reside, | ||
// which we can find from the SourceSet we defined previously. | ||
|
||
testClassesDir = sourceSets.integrationTest.output.classesDir | ||
classpath = sourceSets.integrationTest.runtimeClasspath | ||
|
||
// We must define the directories in which our test reports are written | ||
// for various formats, e.g. binary, HTML, and XML. | ||
|
||
binResultsDir = file("$buildDir/integration-test-results/binary/integrationTest/" + System.getProperty("test.name")) | ||
|
||
reports { | ||
html.destination = "$buildDir/reports/integration-test/" + System.getProperty("test.name") | ||
junitXml.destination = "$buildDir/integration-test-results/" + System.getProperty("test.name") | ||
} | ||
|
||
// As we want our new task to execute after the unit tests, | ||
// we can use the mustRunAfter ordering rule to ensure that | ||
// whenever both of these tasks are in the same execution | ||
// lifecycle (e.g. when running the check task), | ||
// the unit tests are ran before the integration tests. | ||
|
||
mustRunAfter tasks.test | ||
|
||
|
||
} | ||
|
||
// We add our newly created integTest task to the verification | ||
// task lifecycle by making the check task depend upon it. | ||
|
||
check.dependsOn integrationTest | ||
|
||
// In our task’s definition we ensure that it runs after the test task | ||
// that exists within the same project. However, our project structure | ||
// defines multiple sub-projects for which Gradle will create multiple | ||
// individual test tasks. For this reason we must re-evaluate all of the | ||
// other projects once Gradle has finished the Configuration Phase and | ||
// modify our integrationTest task to run after any fast-failing | ||
// tasks (e.g. test) that were created by other sub-projects. | ||
|
||
// We can hook into this part of the build using the projectsEvaluated | ||
// listener which, once triggered, allows us to and iterate over each | ||
// configured project/sub-project to find fast-failing tasks that should | ||
// be prioritized before our integrationTest task within the task execution graph. | ||
|
||
gradle.projectsEvaluated { | ||
// We begin by defining an empty list that will contain tasks that are quick-to-execute. | ||
|
||
def quickTasks = [] | ||
|
||
// Then we iterate over every project that is now configured under the rootProject. | ||
|
||
gradle.rootProject.allprojects.each { project -> | ||
|
||
// Any tasks named test represent the unit tests and are added to the list. | ||
|
||
quickTasks.addAll(project.tasks.findAll { it.name == 'test' }) | ||
|
||
// Tasks whose type are FindBugs or Pmd, | ||
// two static code analysis tools that are quick to analyse | ||
// the entire codebase, are also added. | ||
// We don't use these | ||
|
||
// quickTasks.addAll(project.tasks.withType(FindBugs)) | ||
// quickTasks.addAll(project.tasks.withType(Pmd)) | ||
} | ||
|
||
quickTasks.each { task -> | ||
project.tasks.integrationTest.mustRunAfter task | ||
} | ||
} | ||
|
||
// Let's add the target directory to clean | ||
cleanIntegrationTest.doLast { | ||
file('target').deleteDir() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.