Junit5: 'mvn test' doesn't run tests with maven-surefire-plugin version 3.0.0-M4 when having cucumber 4.8.0 version

Created on 3 Dec 2019  路  13Comments  路  Source: junit-team/junit5

When my project pom contains below build configuration and parent pom has cucumber-4.8.0 version:



org.apache.maven.plugins
maven-surefire-plugin
3.0.0-M4


When I execute mvn test command it is not able to read runner.java class and it is also not able to read .features.

Always it returns:
Running TestRunner Tests run: 0

image

Most helpful comment

There are several inconsistencies in the information that has been provided that make the problem untraceable.

I'd recommend that anybody facing the same problem first decides if they want to use Cucumber with TestNG, JUnit 4 or JUnit 5. If you are unsure which one to choose, pick the one you use for the other tests in your project. If you do not have other test, default to JUnit 4.

After this, make sure the non-chosen integrations are not present. This means that a project should have either cucumber-testng, cucumber-junit or cucumber-junit-platform-engine. So if cucumber-junit was chosen then cucumber-testng and cucumber-junit-platform-engine should not be used as a dependency.

All 13 comments

Could you maybe share your pom please?

and it is also not able to read .features.

How are you launching your Cucumber tests? Do you have a Java class with the Cucumber runner? (like the RunCucumberTest in this example)
You have to import junit-vintage as well, since Cucumber has not yet provided JUnit 5 support (although they seem to be pretty close as https://github.com/cucumber/cucumber-jvm/issues/1149 was closed some days ago).

By using below command i was trying to execute my tests:

mvn -f D:\NisumAutomationPlatform\%Project_PATH%\pom.xml test -DargLine="-Ddc.platformName=Windows -Ddc.browserName=chrome -DtestType=PC -DElementWaitTimeoutInSeconds=30 -Dcucumber.options='--tags @regression'"

And below are my pom dependencies:


junit
junit
4.12


io.cucumber
cucumber-core
4.4.0


io.cucumber
cucumber-testng
4.4.0


io.cucumber
cucumber-java
4.4.0


io.cucumber
cucumber-junit
4.4.0


io.cucumber
cucumber-jvm
4.4.0
pom


net.javacrumbs.json-unit
json-unit-assertj
2.7.0

My TestRunner.Java

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import cucumber.api.testng.CucumberFeatureWrapper;
import cucumber.api.testng.TestNGCucumberRunner;
import org.junit.runner.RunWith;
import org.testng.annotations.*;

//@RunWith(Cucumber.class)
@CucumberOptions(
features = "features",
glue = {"stepdefinitions"},
tags = {"@project_omni_sta"},
plugin = {"pretty",
"html:target/cucumber_target.html", "json:target/cucumber.json"})
public class TestRunner extends AbstractTestNGCucumberTests {

}

issue is resolved after adding
io.cucumber
cucumber-testng
4.4.0

Once I'll update the cucumber version to 4.8.0 and provide a final update

issue is resolved

馃憤

Btw, just be aware that this repository (and therefore this issue tracker) is only dedicated to JUnit 5, I see that you are using JUnit 4 馃槈

Thank you all.. The issue is fixed after adding cucumber-testng in project pom.

@juliette-derancourt I had exactly this issue and solved exactly as @ramareddy88. In case any of you you could explain what's wrong I would be glad. Why I need testing to run unit/cucumber tests via maven?

I honnestly have no clue.

@junit-team/junit-lambda Any ideas?

@UrbanNomadIT I'm not sure what you're asking. It sounds like @ramareddy88 wasn't using JUnit but TestNG to run the Cucumber tests, or am I missing sth.?

There are several inconsistencies in the information that has been provided that make the problem untraceable.

I'd recommend that anybody facing the same problem first decides if they want to use Cucumber with TestNG, JUnit 4 or JUnit 5. If you are unsure which one to choose, pick the one you use for the other tests in your project. If you do not have other test, default to JUnit 4.

After this, make sure the non-chosen integrations are not present. This means that a project should have either cucumber-testng, cucumber-junit or cucumber-junit-platform-engine. So if cucumber-junit was chosen then cucumber-testng and cucumber-junit-platform-engine should not be used as a dependency.

@mpkorstanje Thanks for the detailed explanation! 馃憤

I also resolved the same issue by removing testng from the pom.xml file. But if I have to use testNG to make the test parallel then how can we use that?

Was this page helpful?
0 / 5 - 0 ratings