Steps to reproduce:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss");
String fileName = "raport-" + LocalDateTime.now().format(formatter) + ".html";
ExtentSparkReporter spark = new ExtentSparkReporter(Paths.get( fileName).toFile())
.viewConfigurer()
.viewOrder()
.as(new ViewName[]{ViewName.TEST, ViewName.DASHBOARD, ViewName.EXCEPTION}).apply();
Observed behavior:
Exception in thread "main" java.lang.NullPointerException
at com.aventstack.extentreports.reporter.AbstractFileReporter.<init>(AbstractFileReporter.java:45)
at com.aventstack.extentreports.reporter.ExtentSparkReporter.<init>(ExtentSparkReporter.java:55)
at utils.TestReport.init(TestReport.java:32)
at utils.TestInitialization.init(TestInitialization.java:37)
at listener.ListenerPlugin.onTestRunStarted(ListenerPlugin.java:25)
at io.cucumber.core.eventbus.AbstractEventPublisher.send(AbstractEventPublisher.java:51)
at io.cucumber.core.eventbus.AbstractEventBus.send(AbstractEventBus.java:12)
at io.cucumber.core.runtime.CucumberExecutionContext.emitTestRunStarted(CucumberExecutionContext.java:64)
at io.cucumber.core.runtime.CucumberExecutionContext.startTestRun(CucumberExecutionContext.java:52)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:77)
at io.cucumber.core.cli.Main.run(Main.java:78)
at io.cucumber.core.cli.Main.main(Main.java:33)
Exception throws bolded line if (!parentFile.exists()) {
protected AbstractFileReporter(File f) {
this.file = f;
File parentFile;
if (Files.isDirectory(f.toPath(), new LinkOption[0])) {
parentFile = f;
} else {
parentFile = f.getParentFile();
}
if (!parentFile.exists()) {
parentFile.mkdirs();
}
}
If f argument created without parent folder (new File(fileName.html)), parent file will be always null,
But if argument will be new File (folderName\fileName.html) folder name and parent folder will be successfully created.
Expected behavior:
Argument f cab be just file name without parent folder.
Version: 5.0.4
Steps to reproduce:
Observed behavior:
Exception throws bolded line if (!parentFile.exists()) {
If f argument created without parent folder (new File(fileName.html)), parent file will be always null,
But if argument will be new File (folderName\fileName.html) folder name and parent folder will be successfully created.
Expected behavior:
Argument f cab be just file name without parent folder.
Version: 5.0.4