Gradle + Java + Selenide + Cucumber >> can't configure and retrieve cucumber-report

639 Views Asked by At

Have simple cucumber feature with related auto-test (gradle-selenide) and would like to get 'pretty' cucumber html report.

build.gradle:

plugins {
    id 'java'
    id "com.github.spacialcircumstances.gradle-cucumber-reporting" version "0.1.24"
}


cucumberReports {
    outputDir = file("$buildDir")
    reports = files("$buildDir/cucumber-reports/report.json")
}


group 'org.example'
version '1.0-SNAPSHOT'


repositories {
    mavenCentral()
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'

    testImplementation 'io.cucumber:cucumber-java:7.2.3'
    testImplementation 'io.cucumber:cucumber-junit:7.2.3'

// https://mvnrepository.com/artifact/com.codeborne/selenide
    implementation group: 'com.codeborne', name: 'selenide', version: '6.4.0'
// https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
    implementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.1.1'

}

test {
    systemProperty("webdriver.chrome.driver", "path to chromedriver")
    systemProperty "cucumber.options",     )
    useJUnitPlatform()
}

RunCucumberTest.java

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:build/cucumber-reports/html-report.html", "json:build/cucumber-reports/json-report.json"},
        features = "src/test/resources/features",
        glue = "src/test/java/steps"
)


public class RunCucumberTest {


}

after execution of feature - (even with clean) - no report created on manual execution of generateCucumberReports getting error:

  • What went wrong: Execution failed for task ':generateCucumberReports'.

No test files found

1

There are 1 best solutions below

0
On

found answer on other forum. If someone would face with same issue here is the solution:

a) build.gradle update:

testImplementation "io.cucumber:cucumber-java8:$cucumber"
testImplementation "io.cucumber:cucumber-junit:$cucumber"
testImplementation "io.cucumber:cucumber-junit-platform-engine:$cucumber"

$cucumber = find latest version on MavenRepository

b) create new cucumber.properties file under scr/test/resources with:

configurations {
    cucumberRuntime {
        extendsFrom testImplementation
    }
}

tasks.register('cucumber') {
    dependsOn assemble, testClasses
    doLast {
        javaexec {
            main = 'io.cucumber.core.cli.Main'
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--glue', 'com.tests', 'src/test/resources']
        }
    }
}

if report wouldn't be created automatically - use Terminal > gradlew cucumber