Closed grasshopper7 closed 4 years ago
Ah! Gson does not understand the gherkin classes, thus throwing this error. I will fix this.
Regarding the folder structure, its only for JSON right? Spark should still work.
Nope spark is also not working without an existing folder structure.
fixed issues with TypeAdapter not recognizing Gherkin classes. Working on paths.
Fixed and deployed SNAPSHOT with the 2 fixes.
Note: if paths are supplied like so:
extent.reporter.spark.out=test-output/SparkReport/Spark.html
extent.reporter.json.out=test-output/JsonReport/json.json
Then all file-reporters will resolve them to the file-name.
If they are supplied like:
extent.reporter.spark.out=test-output/SparkReport/
extent.reporter.json.out=test-output/JsonReport/
Files will not be created under SparkReport
or JsonReport
. Instead, 2 files will be created in the below path:
test-output/SparkReport.html
test-output/JsonReport.json
If all looks good - then I think we are ready to release. :)
If they are supplied like:
extent.reporter.spark.out=test-output/SparkReport/ extent.reporter.json.out=test-output/JsonReport/
Files will not be created under
SparkReport
orJsonReport
. Instead, 2 files will be created in the below path:test-output/SparkReport.html test-output/JsonReport.json
I think when creating reports with the above style, to display images for spark the screenshot setting (ie screenshot.rel.path) will need to be modified. Will test and check.
Json report is being generated now.
Works with the first approach when filenames are mentioned.
With the second approach, it is a bit confusing.
extent.reporter.spark.out=test-output/SparkReport/
extent.reporter.json.out=test-output/JsonReport/
On an additional note, suppose from one run of tests images are generated in test-output folder. In the next run, existing images are not deleted but reused. Is this correct behavior?
Okay - for paths then, I will port the version 4 approach.
New images are created for each run, if you check the modified date for each, it will be current.
The latest SNAPSHOT uses v4, which will create a fully qualified file name if user has not supplied a file with the known extensions. Below are the use cases:
test-output/SparkReport -> test-output/SparkReport/Index.html
test-output/SparkReport/ -> test-output/SparkReport/Index.html
test-output/SparkReport/Spark.html -> test-output/SparkReport/Spark.html
Using the above, if:
Works now.
Thanks for the confirmation. I will close this ticket and start preparing for release.
@anshooarora : Any plans of releasing this new version soon ? I am waiting for this JSONFormatter fix :)
It is available in nexus - https://oss.sonatype.org/#nexus-search;quick~extentreports. Both extent and adapter4. U could download or wait for maven central to replicate.
Thanks much :)
Tried adapter v1.2x code with extent V5. Got below exception when creating Json report.
java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: com.aventstack.extentreports.gherkin.model.Feature. Forgot to register a type adapter? at com.google.gson.internal.bind.TypeAdapters$1.write(TypeAdapters.java:73) at com.google.gson.internal.bind.TypeAdapters$1.write(TypeAdapters.java:69) at com.google.gson.TypeAdapter$1.write(TypeAdapter.java:191) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:127) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:245) at com.google.gson.internal.bind.ObjectTypeAdapter.write(ObjectTypeAdapter.java:107) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) at com.google.gson.Gson.toJson(Gson.java:704) at com.google.gson.Gson.toJson(Gson.java:683) at com.google.gson.Gson.toJson(Gson.java:658) at com.aventstack.extentreports.reporter.JsonFormatter.flush(JsonFormatter.java:58) at com.aventstack.extentreports.reporter.JsonFormatter.access$0(JsonFormatter.java:50) at com.aventstack.extentreports.reporter.JsonFormatter$1.onNext(JsonFormatter.java:37) at com.aventstack.extentreports.reporter.JsonFormatter$1.onNext(JsonFormatter.java:1) at io.reactivex.rxjava3.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:310) at io.reactivex.rxjava3.subjects.PublishSubject.onNext(PublishSubject.java:226)
When I make the bddType field in Test.java transient, the report is generated. Similar to what was there in V4, though not sure if this is correct. https://github.com/extent-framework/extentreports-java/blob/1fd8bed14fd4aa1a8f3bb41d4d46c9267ff81416/src/main/java/com/aventstack/extentreports/model/Test.java#L53
Also facing the problem that spark and json report is not generated when folder structure is absent. Similar to this earlier issue. https://github.com/extent-framework/extentreports-cucumber4-adapter/issues/60#issuecomment-651027526