build.gradle でテスト タスクを作成し、それらの特定のタスクを呼び出して、特定の一連のテストを実行する必要があります。クラスが 2 回実行されないようにクラスを除外する例を次に示します (スイートを実行してから、その子クラスを個別に再実行する場合など)。
tasks.withType(Test) {
jvmArgs '-Xms128m', '-Xmx1024m', '-XX:MaxPermSize=128m'
maxParallelForks = 4 // this runs tests parallel if more than one class
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
displayGranularity = 0
}
}
task runAllTests(type: Test) {
include '**/AllTests.class'
testReportDir = file("${reporting.baseDir}/AllTests")
testResultsDir = file("${buildDir}/test-results/AllTests")
}
task runSkipSuite(type: Test) {
include '**/Test*.class'
testReportDir = file("${reporting.baseDir}/Tests")
testResultsDir = file("${buildDir}/test-results/Tests")
}
また、ビルドの質問について。「ビルド」タスクには、ビルド ディレクトリからテストをクリーンアップするクリーン ステップが含まれます。それ以外の場合、実行はテストが既に実行されていると見なします。