在尝试使用Gradle和Java包含使用TestNG运行的测试时,我遇到了问题。排除测试组没有任何问题,但如果我没有指定排除组并尝试仅使用include include语句,则其他测试也会运行。
我的Gradle代码如下:
tasks.withType(Test) {
maxParallelForks = 1
forkEvery = 1000
ignoreFailures = false
systemProperties = System.getProperties()
testLogging.showStandardStreams = true
exclude '**/tasks/'
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', 'broken'
useDefaultListeners = false
listeners << 'org.uncommons.reportng.HTMLReporter'
listeners << 'org.uncommons.reportng.JUnitXMLReporter'
listeners << 'com.xmatters.testng.Listener'
}
reports.junitXml.destination = file("${buildDir}/test-results/firefox")
reports.html.destination = file("${reporting.baseDir}/firefox")
systemProperties.BROWSER = System.getProperty('BROWSER', 'firefox')
exclude '**/selenium/'
exclude '**/setupscripts/'
}
这是给我带来麻烦的人。它包括对msie
组中的那些人进行无组织测试。
task internetExplorer(type: Test) {
testLogging {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "full"
}
useTestNG() {
includeGroups 'msie'
useDefaultListeners = false
listeners << 'org.uncommons.reportng.HTMLReporter'
listeners << 'org.uncommons.reportng.JUnitXMLReporter'
listeners << 'com.xmatters.testng.Listener'
}
reports.junitXml.destination = file("${reporting.baseDir}/internetExplorer")
reports.html.destination = file("${buildDir}/test-results/internetExplorer")
systemProperties.BROWSER = System.getProperty('BROWSER', 'internetExplorer')
exclude '**/selenium/'
exclude '**/setupscripts/
任何帮助或想法都会很棒。
答案 0 :(得分:1)
您似乎没有使用Gradle TestNG插件的“parallel”和“threadcount”选项。相反,你是从Gradle核心分叉。再看看这个:http://www.gradle.org/docs/current/groovydoc/org/gradle/api/tasks/testing/testng/TestNGOptions.html
答案 1 :(得分:0)
我使用 testNG() 部分来设置包含和排除
useTestNG() {
//run classes in parallel, thread count limited by processor.
options {
parallel = 'classes'
threadCount = Runtime.runtime.availableProcessors()
}
listeners << 'com.automation.listeners.TestNgListener'
//sets the default group to run as smoke.*, .* is wildcard.
includeGroups System.getProperty('groups', 'smoke.*')
excludeGroups System.getProperty('excludeGroups', 'exclude')
}
当使用上述结构时,所有未分组的测试都不会运行,但我会努力避免任何没有分组的测试。