javaeclipsecucumberexecutable-jarextentreports

cucumber extent report plugin - NPE when setting parameters as system properties instead of using extent.properties file


I am creating a cucumber project with extent reporting. I have used the cucumber extent adapter 5 plugin. All is working fine while I use extent.properties file for configuration. But when I set the system properties as shown below (instead of properties file)

System.setProperty("extent.reporter.spark.start", "true");
System.setProperty("extent.reporter.spark.config", "spark-config.xml");
System.setProperty("extent.reporter.spark.out", "test-output/sparkReport/");
System.setProperty("extent.reporter.spark.base64imagesrc", "true");
    }

I get an NPE from extent-adapter service class from the below method, even though I have set the value using system properties.

 private static void sparkBase64PngImageStyle() {
      if ("true".equals(String.valueOf(ExtentService.properties.getOrDefault("extent.reporter.spark.base64imagesrc", "false"))))
        ENABLE_BASE64_IMAGE_SRC = true; 
    }

Error:

com.aventstack.extentreports.service.ExtentService.Access$400() returned null

Any pointers will be really helpful. Thanks....


Solution

  • this is how I was able to make it work with the exported JAR.

    1. created a package as com.aventstack.adapter and placed the properties file in this package
    2. Placed the spark-config.xml file in the same folder as the exported JAR file