no "Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, " even that cucumber test was executed using "mvn test" command
Asked Answered
E

5

6

Could someone suggest me a solution why when I run the test using command mvn test to run the cucumber runner class ExampleRunnerTest located in \src\test\java it runs but the maven build doesn't recognize it. Like I said the test runs does what it should do but the build still fails.

1 Scenarios (←[32m1 passed←[0m)
6 Steps (←[32m6 passed←[0m)
1m36.764s

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 98.777 sec - in BasicTest

Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/main/java/cucumber/feature/Basic.feature", glue = "cucumber/stepDefinition",
    format = {"pretty", "html:target/cucumber", "json:target/cucumber-report.json"})

public class BasicTest {
}
Exhalant answered 29/6, 2015 at 13:46 Comment(5)
shouldn't the features be something like classpath:packagename/Basic.feature ?Imprecation
it points to the right feature and the test gets executed, plus in almost all example of runners that I found online they were pointing to a feature like thatExhalant
having the same issues, did you find out the answer to this ?Ane
@adityaparikh , you can solve that by adding the maven-surefire-plugin in your <build> profile section in pom.xmlExhalant
Hey Did you find the solution for this ? I am having same issueResile
P
4

When I had this problem in my Selenium project I realized that I was using junit and TestNG as well. I removed TestNG codes and dependency from pom.xml. This way I only had junit in my project left. Then everything worked like charm, MVN test results showed the correct numbers.

Primalia answered 15/2, 2016 at 9:49 Comment(0)
B
4

@Rai Gupta is right. The dependency was an issue for me also. I saw too many Append your runner class with Test, move the runner class into TEST folder

But you are just destroying the whole design and it will end with a differently designed framework.

JUnit and SureFire plugin need to be aligned. I used

    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.1</version>
        <scope>test</scope>
    </dependency>

And the plugin

    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12.4</version>

However, this produced a parallel execution problem. I did not need it, I removed it eventually. But you can try different versions of the above dependency.

Lastly, this Stack Overflow thread worked for me Tests not running through Maven?

<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter-engine</artifactId>
  <version>5.3.2</version>
</dependency>
Backflow answered 23/1, 2021 at 5:39 Comment(0)
L
1

This is what I did for it to work for me

  1. Like user = BlondCode said remover or comment TestNG dependency from you pom.xml file.

  2. Add JUnit vintage engine dependency to pom.xml

  3. Add a resources folder where you will store your feature and step definitions packages e.g. = \src\test\java\resources\feature and \src\test\java\resources\step definitions

  4. You runner package remains in \src\test\java folder

  5. Last but not the least add the below configuration to surefire plugging. See image below

enter image description here

Lyn answered 21/1, 2021 at 14:44 Comment(0)
A
1

I fixed this issue with JUnit 5 by explicitly adding the following plugins in their latest versions:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.1.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.1.2</version>
            </plugin>
        </plugins>
    </build>

Version 2.x doesn't work.

Amand answered 18/2, 2024 at 21:49 Comment(1)
I was experiencing some version incompatibility too. I did switch to another report plugin for the customized framework i worked on extentreports.comCockscomb
C
0

This could be issue with jUnit supprt in surefire lib. I followed this link to fix the issue.
It works ! Why Your JUnit 5 Tests Are Not Running Under Maven

Customer answered 2/9, 2022 at 10:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.