If the automated test involves a database, etc., it will take a long time to execute. Let's divide it into unit tests and integration tests so that you can easily execute unit tests. It seems that the accuracy of the test will improve if you can test in the combined state every time, but if it takes time and you do not test, it will be overwhelming.
If you use Gradle, the article https://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-integration-testing/ was good, so just make a note of the conclusion.
sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
task integrationTest(type: Test) {
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
Write it like a unit test, place it in src / integration-test / java
, and run it with gradle integrationTest
. The library used only by integrationTest is specified in dependencies
with ʻintegrationTestCompile`.
Recommended Posts