CucumberExtentReporter
CucumberExtentReporter copied to clipboard
Getting null pointer exception
Hi Vimal,
I am building the project with stack: Gradle - Testng - Cucumber-JVM - Selenium - Java
I am trying to integrate extent reports with my project. My project runs fine if I don't add extent report plugin code in my runner file. I start getting null pointer exception with extent report plugin code.
Below is my build.gradle:
`apply plugin: 'java-library' apply plugin: 'application' apply plugin: 'java'
mainClassName = 'com.bdc.neo.main.BdcNeoMain'
repositories {
jcenter()
}
dependencies {
compile(
'org.apache.commons:commons-math3:3.6.1',
'com.google.guava:guava:23.0',
// Use JUnit test framework
'junit:junit:4.12',
'org.testng:testng:6.13.1',
'org.seleniumhq.selenium:selenium-java:3.8.1' ,
'io.cucumber:cucumber-jvm:2.0.0',
'io.cucumber:cucumber-core:2.0.0',
'io.cucumber:cucumber-java:2.0.0',
'io.cucumber:cucumber-testng:2.0.0',
'io.cucumber:cucumber-guice:2.0.0',
'info.cukes:cucumber-html:0.2.6' ,
'io.cucumber:cucumber-jvm-deps:1.0.6',
'io.cucumber:gherkin-jvm-deps:1.0.4',
'io.cucumber:gherkin:4.1.3',
'com.google.inject:guice:4.0',
'javax.inject:javax.inject:1',
'javax.inject:javax.inject-tck:1',
'com.vimalselvam:cucumber-extentsreport:3.0.2',
'com.aventstack:extentreports:3.1.1',
'com.relevantcodes:extentreports:2.41.2'
)
}
test {
testLogging.showStandardStreams = true
systemProperties System.getProperties()
}
`
Below is my sample cucumber runner file:
`package com.bdc.neo.runner;
import cucumber.api.CucumberOptions; import cucumber.api.testng.AbstractTestNGCucumberTests;
import java.io.File;
import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass;
import com.cucumber.listener.ExtentCucumberFormatter; import com.cucumber.listener.ExtentProperties; import com.cucumber.listener.Reporter;
@CucumberOptions( features = {"Feature/Login.feature"}, glue= {"com.bdc.neo.stepdef"}, plugin= {"com.cucumber.listener.ExtentCucumberFormatter:output/Login.html", "json:cucumber/json/LoginTR.json"} )
public class LoginTR extends AbstractTestNGCucumberTests {
// @BeforeClass
// public static void setup()
// {
// ExtentProperties extentProperties = ExtentProperties.INSTANCE;
//// extentProperties.setExtentXServerUrl("http://localhost:1337");
//// extentProperties.setProjectName("MyProject");
// extentProperties.setReportPath("output/myreport.html");
// }
//
// public LoginTR() throws Exception{
// super();
// }
//
@AfterClass
public static void teardown() {
Reporter.loadXMLConfig(new File("src/test/java/extent-config.xml"));
Reporter.setSystemInfo("user", System.getProperty("user.name"));
Reporter.setSystemInfo("os", "Mac OSX");
Reporter.setTestRunnerOutput("Sample test runner output message");
}
}
`
ANd below is the stack trace:
java.lang.NoClassDefError : gherkin/formatter/Reporter
With same settings it works fine without jenkins report plugin.
Please let me know if anything else is required from my end.
Hello Shivani,
I have removed the extended report code from teardown() method, and jenkins has removed 1 out of 2 error as Null Pointer from teardown. But it still showing "NullPointer" error at @BeforeClass > setup() method.
Is there any solution for this?
Thank you
I stumbled over the same issue and found out that the problem is that you are using io.cucumber
packages instead of the info.cukes
which are the older package names for io.cucumber
and still used by this project. I already created an issue about that.
When I find some spare time I might create a branch which uses the new io.cucumber
packages instead if the older ones.