damianszczepanik / cucumber-reporting

HTML reports for Cucumber
GNU Lesser General Public License v2.1
546 stars 402 forks source link

net.masterthought.cucumber.ValidationException: File 'cucumber.json' is not proper Cucumber report! #709

Closed baernhaut closed 6 years ago

baernhaut commented 6 years ago

Hello, I've read the two issues regarding this Exception.

Somehow mine is a little bit different: I checked if the encoding is correct and the JSON File is encoded in UTF-8. So that should be fine.

The thing is, when I run my tests and call the ReportBuilder on the JSON-File currently generated, i get this Exception. If I run the test and generate a Report of the json file from a prior Run, there is no problem.

So I guess my program is not done generating the JSON file? I'm calling the ReportGenerator in @AfterClass in my Runnerclass. Also tried to apply it in @After (cucumber) in my stepdefinition of the scenario.

Full exception:

net.masterthought.cucumber.ValidationException: File 'cucumber-json-report.json' is not proper Cucumber report! at net.masterthought.cucumber.ReportParser.parseForFeature(ReportParser.java:87) at net.masterthought.cucumber.ReportParser.parseJsonFiles(ReportParser.java:58) at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:76) at at.gv.bmf.ear.test.regr.RunAllCucumberTests.after(RunAllCucumberTests.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at cucumber.api.junit.Cucumber.run(Cucumber.java:100) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: java.io.InputStreamReader@340b7ef6; line: 1, column: 0] at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:261) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3829) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3774) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2878) at net.masterthought.cucumber.ReportParser.parseForFeature(ReportParser.java:81) ... 18 more

I'm not attaching a JSON File, because it is working, if I call an older ( even the run before) JSON-file, when i start a new Run.

here's my runnerClass: `@RunWith(Cucumber.class) @CucumberOptions(features = "src/test/resources/regr", glue = { "path_to_gluecode" }, tags = { "@presentation" }, plugin = {"pretty", "json:cucumber-json-report.json"}, monochrome = true) public class RunAllCucumberTests {

@After
public static void after() throws Throwable{
    File reportOutputDirectory = new File("target");

    List<String> jsonFiles = new ArrayList<>();
    jsonFiles.add("cucumber-json-report.json");

    String buildNumber = "1";
    String projectName = "projektReport";
    boolean runWithJenkins = false;
    boolean parallelTesting = false;

    Configuration configuration = new Configuration(reportOutputDirectory,projectName);
    configuration.setParallelTesting(parallelTesting);
    configuration.setRunWithJenkins(runWithJenkins);
    configuration.setBuildNumber(buildNumber);

    ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
    Reportable result = reportBuilder.generateReports();
}`

Thanks a lot.

damianszczepanik commented 6 years ago

Show me that JSON file first.

baernhaut commented 6 years ago

There it is. I've done some more research, and I've seen that in maven projects there is the maven-cucumber-reporting artifact, which can be executed in this form:

  • < executions> -< execution> < id>execution< /id> < phase>verify< /phase> -< goals> < goal>generate< /goal> < /goals> -< configuration> < projectName>Testing< /projectName> < outputDirectory>${project.build.directory}/site/cucumber-reports< /outputDirectory> < cucumberOutput>${project.build.directory}/site/cucumber-reports-json/< /cucumberOutput> < buildNumber>${project.version}< /buildNumber> < /configuration> < /execution> < /executions>

Is there a way to accomblish the same in gradle?

[ { "comments": [ { "line": 1, "value": "#language:de" }, { "line": 2, "value": "## RDNG: comment1" }, { "line": 3, "value": "## RQM: comment2" }, { "line": 4, "value": "##" }, { "line": 5, "value": "## notes" }, { "line": 6, "value": "## - note1" }, { "line": 7, "value": "## - note2" }, { "line": 8, "value": "##" } ], "line": 10, "elements": [ { "line": 12, "name": "", "description": "", "type": "background", "keyword": "Grundlage" }, { "line": 53, "name": "01 - scenarioname", "description": "\r\ comment", "type": "scenario", "keyword": "Szenariogrundriss", "steps": [ { "result": { "duration": 19103752096, "status": "passed" }, "line": 23, "name": "step1 "", "match": { "arguments": [ { "val": "value1", "offset": 28 } ], "location": "SetupGlueCode.method1()" }, "matchedColumns": [ 4 ], "keyword": "Angenommen " }, { "result": { "duration": 389094606, "status": "passed" }, "line": 24, "name": "step2", "match": { "arguments": [ { "val": "value2", "offset": 37 } ], "location": "SetupGlueCode.method2(String)" }, "keyword": "Und " }, { "result": { "duration": 1613708007, "error_message": "org.junit.ComparisonFailure: exception message. ", "status": "failed" }, "line": 25, "name": "step3"", "match": { "arguments": [ { "val": "value3", "offset": 26 } ], "location": "method3()" }, "keyword": "Und " }, { "result": { "status": "skipped" }, "line": 27, "name": "step4"", "match": { "arguments": [ { "val": "value", "offset": 42 }, { "val": "value", "offset": 63 }, { "val": "value", "offset": 84 } ], "location": "method4(String,String,String)" }, "keyword": "Und " }, { "result": { "status": "skipped" }, "line": 29, "name": "step5", "match": { "arguments": [ { "val": "value", "offset": 22 } ], "location": "method5()" }, "keyword": "Angenommen " }, { "result": { "status": "skipped" }, "line": 30, "name": "step6", "match": { "arguments": [ { "val": "value6", "offset": 36 } ], "location": "method6()" }, "keyword": "Dann " }, { "result": { "status": "skipped" }, "line": 32, "name": "step7", "match": { "arguments": [ { "val": "100,00", "offset": 26 } ], "location": "method7(String)" }, "matchedColumns": [ 0 ], "keyword": "Wenn " }, { "result": { "status": "skipped" }, "line": 33, "name": "step8", "match": { "arguments": [ { "val": "value8", "offset": 15 } ], "location": "method8(String)" }, "matchedColumns": [ 2 ], "keyword": "Und " }, { "result": { "status": "skipped" }, "line": 34, "name": "step9", "match": { "arguments": [ { "val": "value9", "offset": 12 } ], "location": "method9(String)" }, "matchedColumns": [ 1 ], "keyword": "Und " }, { "result": { "status": "skipped" }, "line": 36, "name": "step10", "match": { "arguments": [ { "val": "value", "offset": 48 } ], "location": "method10(String)" }, "keyword": "Dann " }, { "result": { "status": "skipped" }, "line": 38, "name": "step11", "match": { "arguments": [ { "val": "value", "offset": 5 } ], "location": "method11(String)" }, "matchedColumns": [ 3 ], "keyword": "Wenn " }, { "result": { "status": "skipped" }, "line": 39, "name": "step12", "match": { "arguments": [ { "val": "value12", "offset": 16 } ], "location": "method12" }, "matchedColumns": [ 0, 1, 2, 3 ], "rows": [ { "cells": [ "value", "100,00" ], "line": 40 }, { "cells": [ "value", "value-value" ], "line": 41 }, { "cells": [ "value", "value-value" ], "line": 42 }, { "cells": [ "value", "value-value" ], "line": 43 } ], "keyword": "Dann " }, { "result": { "status": "skipped" }, "line": 45, "name": "step13", "match": { "location": "method13()" }, "keyword": "Wenn " }, { "result": { "status": "skipped" }, "line": 46, "name": "step14", "match": { "arguments": [ { "val": "value14", "offset": 25 } ], "location": "method14" }, "keyword": "Dann " }, { "result": { "status": "skipped" }, "line": 47, "name": "step15", "match": { "arguments": [ { "val": "value", "offset": 15 }, { "val": "100,00", "offset": 38 }, { "val": "value", "offset": 52 } ], "location": "method15()" }, "matchedColumns": [ 0 ], "keyword": "Und " }, { "result": { "status": "skipped" }, "line": 48, "name": "step16", "match": { "arguments": [ { "val": "value", "offset": 15 }, { "val": "100,00", "offset": 43 }, { "val": "value", "offset": 57 } ], "location": "method16()" }, "matchedColumns": [ 0 ], "keyword": "Und " }, { "result": { "status": "skipped" }, "line": 49, "name": "step17", "match": { "arguments": [ { "val": "value", "offset": 15 }, { "val": "value", "offset": 34 } ], "location": "method17()" }, "keyword": "Und " } ], "tags": [ { "line": 9, "name": "@UI-Tested" }, { "line": 14, "name": "@presentation" }, { "line": 9, "name": "@tag1" }, { "line": 9, "name": "@tag2" } ] } ], "name": "Test_name", "description": "", "id": "test_id", "keyword": "Funktionalität", "uri": "feature.feature", "tags": [ { "line": 9, "name": "@UI-Tested" }, { "line": 9, "name": "@tag1" }, { "line": 9, "name": "@tag2" } ] } ]

damianszczepanik commented 6 years ago

Guys, this is not even correct JSON file (so it could not be a cucumber as well)!