- task: Gradle@3
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'clean build test -PincludeTags="LoginFeature" --info'
displayName: 'Testing'
收到此错误:
CucumberTestRunner > initializationError FAILED
org.junit.platform.suite.engine.NoTestsDiscoveredException: Suite [com.app.x.CucumberTestRunner] did not discover any tests
at [email protected]/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at [email protected]/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at [email protected]/java.util.Iterator.forEachRemaining(Iterator.java:133)
如果我执行以下执行:
- script: |
chmod +x gradlew
./gradlew clean build test -PincludeTags="LoginFeature" --info
它通常在我的本地机器上工作...
我不确定为什么在DevOps管道上跑步者没有看到功能文件...任何帮助都将不胜感激。 我的功能文件位于
src/test/resources/com/app/x/features
这是我的跑步者:
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/app/x/features")
@SelectPackages(*arrayOf("com.app.x", "com.app.library"))
@ConfigurationParameter(key = io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME, value = "com.app.x,com.app.library")
@ConfigurationParameter(key = io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME,value = "pretty,summary,com.app.x.integrations.CucumberEventListener, html:target/cucumber-report/cucumber.html")
class CucumberTestRunner
这是gradle
import com.gradle.cucumber.companion.generateCucumberSuiteCompanion
import java.util.*
plugins {
id("org.jetbrains.kotlin.jvm") version ("1.9.20")
java
}
tasks {
test {
useJUnitPlatform {
// OPTIONAL: Include only specified tags using JUnit5 tag expressions
if (project.hasProperty("includeTags")) {
println("project included includeTags: ${project.property("includeTags")}")
includeTags(project.property("includeTags") as String?)
} else {
val properties = Properties()
val configFile = System.getenv("configurationFile") ?: "configuration.properties"
println("using configuration file: $configFile")
file("src/test/resources/$configFile").inputStream().use { properties.load(it) }
val tags = properties.getProperty("tags")
println("project didnt include includeTags: $tags")
includeTags(tags.replace("@", ""))
}
}
// OPTIONAL: Ignore test failures so that build pipelines won't get blocked by failing examples/scenarios
ignoreFailures = true
// OPTIONAL: Copy all system properties from the command line (-D...) to the test environment
systemProperties(project.gradle.startParameter.systemPropertiesArgs)
// OPTIONAL: Enable parallel test execution
systemProperty("cucumber.execution.parallel.enabled", true)
// OPTIONAL: Set parallel execution strategy (defaults to dynamic)
systemProperty("cucumber.execution.parallel.config.strategy", "fixed")
// OPTIONAL: Set the fixed number of parallel test executions. Only works for the "fixed" strategy defined above
systemProperty("cucumber.execution.parallel.config.fixed.parallelism", 4)
// OPTIONAL: Enable Cucumber plugins, enable/disable as desired
systemProperty("cucumber.plugin", "message:build/reports/cucumber.ndjson, timeline:build/reports/timeline, html:build/reports/cucumber.html")
// OPTIONAL: Improve readability of test names in reports
systemProperty("cucumber.junit-platform.naming-strategy", "long")
// OPTIONAL: Force test execution even if they are up-to-date according to Gradle or use "gradle test --rerun"
outputs.upToDateWhen { false }
val reportsDir = file("$buildDir/test-results")
outputs.dir(reportsDir)
systemProperty("reports-dir", reportsDir)
include("**/CucumberTestRunner.*")
}
}
configurations {
all {
// OPTIONAL: Exclude JUnit 4
exclude(group = "junit", module = "junit")
// OPTIONAL: Exclude JUnit 5 vintage engine
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
// OPTIONAL: Exclude JUnit 5 jupiter engine
exclude(group = "org.junit.jupiter", module = "junit-jupiter-engine")
}
}
kotlin {
sourceSets {
val main by getting {
kotlin.srcDir("src/main/kotlin")
resources.srcDir("src/main/resources")
}
val test by getting {
kotlin.srcDir("src/test/kotlin") // Ensure this is set correctly
resources.srcDir("src/test/resources")
}
}
}
我尝试添加
id("com.gradle.cucumber.companion") version "1.3.0"
从
Https://github.com/gradle/cucumber-companion?tab = readme-ov-file但尚不清楚它的作用,无论如何它没有效果。
在下面的每个任务代码,在linux/macos
代理上,它将通过强制CHMOD将gradlew文件设置为可执行文件。在
Windows
上,它将将.bat扩展名附加到gradlew脚本。