1

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>
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
Leponzo
  • 624
  • 1
  • 8
  • 20
  • There are two different things. The tests show only skipped and successfully executed tests but no failure...The question is where is the relationship between those two outputs..? Please post the full test, the full pom file etc. otherwise there is no chance to say something or even speculate... – khmarbaise Jan 04 '21 at 22:27
  • Do you use TestNg or JUnit? – Fenio Jan 05 '21 at 12:02
  • @Fenio Yes, the issue was related to them, as I answered below now. – Leponzo Jan 05 '21 at 13:28

1 Answers1

2

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.

Leponzo
  • 624
  • 1
  • 8
  • 20