Leponzo
Leponzo

Reputation: 656

mvn test doesn't fail when Cucumber scenario fails

I have a RunCucumberTest class as described in the JUnit section here and a Cucumber scenario that fails when run from the gutter icon in IntelliJ.

However, why does mvn test build successfully?

[WARNING] Tests run: 482, Failures: 0, Errors: 0, Skipped: 12
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:10 min
[INFO] Finished at: 2021-01-04T15:54:51-05:00
[INFO] ------------------------------------------------------------------------

I can see in the log that the scenario failed:

............................................F--.....................................................................................
Failed scenarios:
com/rose/sample.feature:23 # Feature name
26 Scenarios (1 failed, 25 passed)
132 Steps (1 failed, 2 skipped, 129 passed)
0m0.596s
org.junit.ComparisonFailure: expected:<x> but was:<y>

Upvotes: 1

Views: 1960

Answers (2)

Mohan krishna Sridhar
Mohan krishna Sridhar

Reputation: 43

This works for me. Add/update testFailureIgnore as "false" in pom.xml file

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                    <argLine>${argLine}</argLine>
                </configuration>
            </plugin>

Upvotes: 0

Leponzo
Leponzo

Reputation: 656

After further Googling, I finally figured out the problem was due to having both JUnit and TestNG as dependencies in my project while using the JUnit Cucumber runner. Since I couldn't remove the JUnit and TestNG dependencies as they were inherited from a parent POM, I changed the Cucumber runner to use TestNG instead and it worked.


I later found another, simpler solution: https://stackoverflow.com/a/19928639/4179032.

Upvotes: 2

Related Questions