在尝试使用Gradle和Java在TestNG中运行测试时,我遇到了一些问题。排除测试组没有任何问题,但是如果我不指定排除组并尝试只使用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/任何帮助或想法都是很棒的。
发布于 2014-01-09 08:17:15
您似乎没有使用Gradle TestNG插件的“并行”和“线程计数”选项。相反,你是从Gradle核心派生出来的。再看看这个:http://www.gradle.org/docs/current/groovydoc/org/gradle/api/tasks/testing/testng/TestNGOptions.html
发布于 2021-02-09 00:47:35
我使用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')
}当使用上面的结构时,所有未分组的测试都不会运行,但我会努力不让任何没有分组的测试。
https://stackoverflow.com/questions/21009125
复制相似问题