Discussion:
[Cucumber] [Cucumber-jvm] Cannot inject @Test with parameters CucumberFeatureWrapper
(too old to reply)
Wong Peter
2018-04-12 02:32:50 UTC
Permalink
Raw Message
I running a project using BDD Cucumber and TestNG but it encounter error at
below.

Cannot inject @Test annotated Method [feature] with [interface cucumber.api.testng.CucumberFeatureWrapper].
For more information on native dependency injection please refer to http://testng.org/doc/documentation-main.html#nativ
e-dependency-injection


I know that @Test method can only have @ITestContext annotation. How to run my feature file?

I using version 2.4.0 for cucumber-jvm. Any concrete examples?
@CucumberOptions(
features = "src/Feature",
glue = {"Step_Definitions"},
plugin = {
"pretty",
"html:target/cucumber-reports/cucumber-pretty",
"json:target/cucumber-reports/CucumberTestReport.json",
"rerun:target/cucumber-reports/rerun.txt"
})
public class TestRunner {
private TestNGCucumberRunner testNGCucumberRunner;
private ExtentReportManager reportMgr;
private PropertiesManager pm;

@BeforeTest(alwaysRun = true)
public void setUp() throws Exception {
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());

pm = PropertiesManager.createInstance();
reportMgr = ExtentReportManager.createInstance();

WebDriverManager.createDriver();
}

@Test(groups = "cucumber", description = "Runs Cucumber Feature"/*, dataProvider = "dataProvider"*/)
public void feature(CucumberFeatureWrapper cucumberFeature) {
//ITestContext context
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}



/*@DataProvider(name = "dataProvider", parallel = true)
public Object[][] features() {
return testNGCucumberRunner.provideFeatures();
}*/

@AfterTest(alwaysRun = true)
public void tearDown() throws Exception {
reportMgr.getExtent().flush();
testNGCucumberRunner.finish();
}



Please help. Thanks.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wong Peter
2018-04-12 08:06:07 UTC
Permalink
Raw Message
Problem solved.
Post by Wong Peter
I running a project using BDD Cucumber and TestNG but it encounter error
at below.
For more information on native dependency injection please refer to http://testng.org/doc/documentation-main.html#nativ
e-dependency-injection
I using version 2.4.0 for cucumber-jvm. Any concrete examples?
@CucumberOptions(
features = "src/Feature",
glue = {"Step_Definitions"},
plugin = {
"pretty",
"html:target/cucumber-reports/cucumber-pretty",
"json:target/cucumber-reports/CucumberTestReport.json",
"rerun:target/cucumber-reports/rerun.txt"
})
public class TestRunner {
private TestNGCucumberRunner testNGCucumberRunner;
private ExtentReportManager reportMgr;
private PropertiesManager pm;
@BeforeTest(alwaysRun = true)
public void setUp() throws Exception {
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
pm = PropertiesManager.createInstance();
reportMgr = ExtentReportManager.createInstance();
WebDriverManager.createDriver();
}
@Test(groups = "cucumber", description = "Runs Cucumber Feature"/*, dataProvider = "dataProvider"*/)
public void feature(CucumberFeatureWrapper cucumberFeature) {
//ITestContext context
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}
public Object[][] features() {
return testNGCucumberRunner.provideFeatures();
}*/
@AfterTest(alwaysRun = true)
public void tearDown() throws Exception {
reportMgr.getExtent().flush();
testNGCucumberRunner.finish();
}
Please help. Thanks.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
MP Korstanje
2018-04-12 14:28:42 UTC
Permalink
Raw Message
Nothing more annoying then finding a post with your problem that has been
solved, but still without an answer. :)

For reference cucumber JVM keeps an examples section in the source code:

https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng
Post by Wong Peter
Problem solved.
Post by Wong Peter
I running a project using BDD Cucumber and TestNG but it encounter error
at below.
For more information on native dependency injection please refer to http://testng.org/doc/documentation-main.html#nativ
e-dependency-injection
I using version 2.4.0 for cucumber-jvm. Any concrete examples?
@CucumberOptions(
features = "src/Feature",
glue = {"Step_Definitions"},
plugin = {
"pretty",
"html:target/cucumber-reports/cucumber-pretty",
"json:target/cucumber-reports/CucumberTestReport.json",
"rerun:target/cucumber-reports/rerun.txt"
})
public class TestRunner {
private TestNGCucumberRunner testNGCucumberRunner;
private ExtentReportManager reportMgr;
private PropertiesManager pm;
@BeforeTest(alwaysRun = true)
public void setUp() throws Exception {
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
pm = PropertiesManager.createInstance();
reportMgr = ExtentReportManager.createInstance();
WebDriverManager.createDriver();
}
@Test(groups = "cucumber", description = "Runs Cucumber Feature"/*, dataProvider = "dataProvider"*/)
public void feature(CucumberFeatureWrapper cucumberFeature) {
//ITestContext context
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}
public Object[][] features() {
return testNGCucumberRunner.provideFeatures();
}*/
@AfterTest(alwaysRun = true)
public void tearDown() throws Exception {
reportMgr.getExtent().flush();
testNGCucumberRunner.finish();
}
Please help. Thanks.
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...