更新が必要な Selenium テスト用に設定した「検疫」フォルダーを除外しようとしていますが、実行したくありません。解決策の 1 つは、これらのクラスのテストにテスト グループを設定して割り当てることだとわかっていますが、ここに含まれるテストの規模と量を考えると、Ant スタイルのフィルターを使用したいと思います。
これが私のbuild.gradle
ファイルのスニペットです:
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
repositories {
mavenCentral()
}
dependencies {
compile "org.seleniumhq.selenium:selenium-java:2.35.0"
compile "org.testng:testng:5.14.10"
testCompile('org.uncommons:reportng:1.1.2') {
exclude group: 'org.testng'
}
testCompile "junit:junit:4.8.2"
compile "com.jayway.restassured:rest-assured:1.8.1"
}
//initialize thread count variable for parallel testing and default to 1
def threadCount = System.getProperty("MAXTHREADS", "1")
tasks.withType(Test) {
maxParallelForks = 1
forkEvery = 1000
ignoreFailures = false
// Pass all system properties to the tests
systemProperties = System.getProperties()
// Makes the standard streams (err and out) visible at console when running tests
testLogging.showStandardStreams = true
exclude '**/tasks/'
exclude '**/disabled/'
classpath += configurations.testCompile
}
task firefox(type: Test) {
maxParallelForks = Integer.valueOf(threadCount) //default is 1 if not specified
testLogging.events "started"
testLogging {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "full" // default is "short"
}
useTestNG() {
excludeGroups 'chrome'
useDefaultListeners = false
listeners << 'org.uncommons.reportng.HTMLReporter'
listeners << 'org.uncommons.reportng.JUnitXMLReporter'
listeners << 'com.xmatters.testng.Listener'
}
testResultsDir = file("${buildDir}/test-results/firefox")
testReportDir = file("${reporting.baseDir}/firefox")
systemProperties.BROWSER = System.getProperty('BROWSER', 'firefox')
exclude '**/selenium/'
exclude '**/setupscripts/'
}
task chrome(type: Test) {
maxParallelForks = Integer.valueOf(threadCount) //default is 1 if not specified
testLogging.events "started"
useTestNG() {
useDefaultListeners = false;
listeners << 'org.uncommons.reportng.HTMLReporter'
listeners << 'org.uncommons.reportng.JUnitXMLReporter'
listeners << 'com.xmatters.testng.Listener'
}
testResultsDir = file("${buildDir}/test-results/chrome")
testReportDir = file("${reporting.baseDir}/chrome")
systemProperties.BROWSER = System.getProperty('BROWSER', 'chrome')
exclude '**/selenium/'
exclude '**/setupscripts/'
}
34 行目で、私が追加したことがわかりますexclude '**/disabled/'
。このフォルダーは、ルート フォルダーから 2 つ上のレベルにあります。前の likeexclude '**/tasks/'
は既にビルド ファイルに含まれており、同様のディレクトリ構造で問題なく動作するようです。
ビルドを実行すると、/disabled/ フォルダー内のテストがまだ実行されています。ここで私が間違っていることはありますか?その構文では、「除外」という名前のディレクトリが2つ上のレベルで無視されると想定していscanForTestClasses
ます。これはデフォルトでtrueです。ここに何があるか分かりますか?
Gradle テスト レポートで気付いたもう 1 つのことは、レポートにリストされているパッケージ名は、default-package
「除外」されていない除外されたテスト用であるのに対し、実行される予定の他のテストは正しいパッケージ名をリストしていることです。Java ファイルのパッケージ名はフォルダ構造と正しく一致しているため、なぜこのように報告されているのかわかりません。重複、タイプミスなどをチェックしましたが、どこにも行きません。
これらの不完全な/壊れたテストクラスを実行すると、これらのテストが更新されるまで無視する必要がある障害が発生するため、誰かがこれに光を当てることができれば素晴らしいでしょう。
これらのテストは、Linux で実行されているテスト CI (Jenkins) ボックスで、Gradle ラッパーによって生成された bash スクリプトを使用して実行されています。