Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ramareddy88 opened this issue Dec 3, 2019 · 14 comments

Comments

@ramareddy88
Copy link

ramareddy88 commented Dec 3, 2019

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

@ramareddy88 ramareddy88 changed the title 'mvn test' doesn't run tests with maven-surefire-plugin version 3.0.0-M4 when having cucumber 4.8.0 version 'mvn test' doesn't run tests with maven-surefire-plugin version 3.0.0-M4 when having cucumber 4.8.0 version intuit/karate Dec 3, 2019
@ramareddy88 ramareddy88 changed the title 'mvn test' doesn't run tests with maven-surefire-plugin version 3.0.0-M4 when having cucumber 4.8.0 version intuit/karate 'mvn test' doesn't run tests with maven-surefire-plugin version 3.0.0-M4 when having cucumber 4.8.0 version Dec 3, 2019
@juliette-derancourt
Copy link
Member

juliette-derancourt commented Dec 3, 2019

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 cucumber/cucumber-jvm#1149 was closed some days ago).

@ramareddy88
Copy link
Author

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

@ramareddy88
Copy link
Author

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 {

}

@ramareddy88
Copy link
Author

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

@ramareddy88
Copy link
Author

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

@juliette-derancourt
Copy link
Member

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 😉

@ramareddy88
Copy link
Author

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

@UrbanNomadIT
Copy link

@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?

@juliette-derancourt
Copy link
Member

I honnestly have no clue.

@junit-team/junit-lambda Any ideas?

@marcphilipp
Copy link
Member

@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.?

@mpkorstanje
Copy link
Contributor

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.

@marcphilipp
Copy link
Member

@mpkorstanje Thanks for the detailed explanation! 👍

@sourisengupta
Copy link

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?

@Nikasan
Copy link

Nikasan commented Nov 18, 2021

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?

the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants