0
votes

I want to create simply selenium project for Jenkins. When I run my test with Runner.java then output show me 0 scenarios. When I run my test with mvn, e.g.mvn clean verify -Dcucumber.options="--tags @smoke" output show me BUILD SUCCESS

All my classes is in src/test/java/package

Runner: src/test/java/runner/Runner.java

Glue: src/test/java/glue/login/LoginDef.java src/test/java/glue/dashboard/DashboardDef.java

cucumber's file src/test/resources/login/login.feature src/test/resources/smoke/page.feature

Below is screenshot my folders structure https://prnt.sc/nwov73

I have no idea where is problem ;/ I used google before I asked and I not found solution...

@RunWith(Cucumber.class)
@CucumberOptions(
        strict = true,
        features = {"src/test/resources/features"},
        plugin = {"json:build/reports/cucumberRunner.json", "html:build/reports/html", "pretty"},
        monochrome = true,
        tags = {"not @ignore", "not @wip", "@login", "@smoke"},
        glue = {"src/test/java/glue", "hooks"}
)
public class Runner {
}
    <properties>
        <io.cucumber.gherkin>5.1.0</io.cucumber.gherkin>
        <io.cucumber.common>4.3.1</io.cucumber.common>
        <selenide>5.2.3</selenide>
        <lombok>1.18.4</lombok>
        <junit>4.12</junit>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>${io.cucumber.gherkin}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java8</artifactId>
            <version>${io.cucumber.common}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${io.cucumber.common}</version>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>io.cucumber</groupId>-->
            <!--<artifactId>cucumber-jvm</artifactId>-->
            <!--<version>${io.cucumber.common}</version>-->
        <!--</dependency>-->

        <!-- junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit}</version>
        </dependency>

        <!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok}</version>
            <scope>provided</scope>
        </dependency>

        <!-- selenide -->
        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide</artifactId>
            <version>${selenide}</version>
        <!-- <scope>test</scope>-->
     </dependency>
    </dependencies>

    <build>
        <!--<testSourceDirectory>src/test/resources/features/</testSourceDirectory>-->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M3</version>
            </plugin>
        </plugins>
    </build>
</project>

Edit: I change Runner.java to RunnerTest.java. Mvn execute tests but all tests fail. All steps has "You can implement missing steps with the snippets below:" ;/

Edit2: I remove "@" from tags in RunnerTest.java and currently I have always "0 Scenarios 0 Steps 0m0.093s"

Edit 3 - problem solved. I don't have path in glue to class where I have driver config. actually my glue - glue = {"glue", "config/browser"}. Before I had only {"glue"}.

1
cucumber cannot find your step def implementation. change glue option to glue = "glue". Do not see any hooks package, why have u added it. No need for gherkin and junit dependecies, they will be pulled in automatically. For automatic inclusion of test class by surefire check this - maven.apache.org/surefire/maven-surefire-plugin/examples/…Grasshopper
I changed glue option to glue = {"glue"}, i removed <artifactId>gherkin</artifactId> and <artifactId>junit</artifactId> and still I have 0 scenarios :(cana123
Use this in tags option-- tags = {"@login or @smoke"}Grasshopper
doesn't work, still [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.568 s - in runner.RunnerTestcana123

1 Answers

1
votes

Please update the POM dependencies correctly. gherkin, junit etc are transitive dependencies which would be taken care by maven when you add direct dependencies.

Key Point : We shall not mix direct & transitive dependencies specially their versions! Doing so can cause unpredictable outcome.

You may prefer below correct set of io.cucumber dependencies and update cucumber v as per your framework need.

 <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.2.6</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.2.6</version>
</dependency>