Discussion:
[Cucumber] [Cucumber-jvm] Clash between Cucumber Hook and TestNG Hook
(too old to reply)
Wong Peter
2018-04-11 07:20:53 UTC
Permalink
Raw Message
Hello to all, I have implement TestNG hook using @BeforeTest annotation and
Cucumber hoo using @Before annotation but there is an error showing when
running the code.

[Utils] [ERROR] [Error] java.lang.NullPointerException
at Runner.TestRunner.features(TestRunner.java:105)

FAILED CONFIGURATION: @BeforeTest setUp
java.lang.NoClassDefFoundError:
io/cucumber/tagexpressions/TagExpressionParser
at cucumber.runtime.TagPredicate.<init>(TagPredicate.java:23)

Caused by: java.lang.ClassNotFoundException:
io.cucumber.tagexpressions.TagExpressionParser

FAILED CONFIGURATION: @AfterTest tearDown
java.lang.NullPointerException
at Runner.TestRunner.tearDown(TestRunner.java:110)


Login.java
public class Login {
private PropertiesManager pm;
private ExtentReportManager reportMgr;
public Login() {
}
/*@Before("@p")
public void setUp() {
pm = PropertiesManager.createInstance();
reportMgr = ExtentReportManager.createInstance();
}*/
}

TestRunner.java
@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) {

testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}
}

Why there is clash between Cucumber hook and TestNG hook? How to solve it?
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...