Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

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 {
                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 that
– Wojciech
                Jun 29, 2015 at 14:04
                @adityaparikh , you can solve that by adding the maven-surefire-plugin in your <build> profile section in pom.xml
– Wojciech
                Jan 29, 2016 at 17:04
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" etc. 

But you are just destroying the whole design and it will end with 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>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
However, this came in with a parallel execution problem. I did not need it, removed. But you can try different versions of the above dependency.

Lastly, this worked or me: Tests not running through Maven?

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.3.2</version>
    </dependency>

This is what I did for it to work for me

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

  • Add JUnit vintage engine dependency to pom.xml

  • 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

  • You runner package remains in \src\test\java folder

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

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •