问题描述 投票:0回答:1

- 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脚本。

gradle azure-pipelines junit5 cucumber-jvm
1个回答
0
投票

仅从Windows提交的人永远不会注意到他们的Gradlew(SH)文件是无法执行的。 Windows不支持执行属性,Windows的Gradle依赖于gradlew.bat.

因此,您可以尝试以下选项:
将DevOps代理更改为Linux类型(例如:Ubuntu代理),然后再次运行。

或先前的脚本任务,the Gradle@3任务。

或运行chmod +x gradlewenter image description here并承诺修复文件属性。

请检查

link

以获取更多详细信息。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.