Update Cucumber.json

616 views
Skip to first unread message

AutomationQA

unread,
May 25, 2015, 3:06:44 PM5/25/15
to cu...@googlegroups.com
Hi All,

I am using Cucumber JVM with JUnit having following plugin options

 plugin     =   {"html:target/cucumber" , "json:target/cucumber.json" },

The cucumber.json file is created after the execution is completed whereas I need to update this json file at runtime to change the node values such as status and error description.

Please let me know how can I access and modify this json file at runtime.

Thanks in advance.

Regards
Shobhit

Paolo Ambrosio

unread,
May 25, 2015, 3:36:21 PM5/25/15
to cu...@googlegroups.com
Why you need to do it at runtime? It would be so much easier to
convert the json afterwards.

If there is nothing you can do to avoid it, I suppose you could write
your own formatter. You can try and understand how they work by
looking at the existing formatters:

https://github.com/cucumber/cucumber-jvm/tree/master/core/src/main/java/cucumber/runtime/formatter

AutomationQA

unread,
May 26, 2015, 1:11:38 AM5/26/15
to cu...@googlegroups.com
Firstly I have to extract the information like duration after each scenario is executed. Also I am trying to avoid publishing the whole Assertion error stack trace in the JSON file as we have to share the reports with the BA , so don't want to publish any technical details in the report. Instead of using assertion , I want to mark the step as failed based on some flag which I believe can be done by changing the node result - > status as "Failed"

I am using Masterthought plugin which reads this json file to create its interactive reports.

Paolo Ambrosio

unread,
May 26, 2015, 2:34:44 AM5/26/15
to cu...@googlegroups.com
On Tue, May 26, 2015 at 6:11 AM, AutomationQA
<shobhitg...@gmail.com> wrote:

> Firstly I have to extract the information like duration after each scenario
> is executed. Also I am trying to avoid publishing the whole Assertion error
> stack trace in the JSON file as we have to share the reports with the BA ,
> so don't want to publish any technical details in the report. Instead of
> using assertion , I want to mark the step as failed based on some flag which
> I believe can be done by changing the node result - > status as "Failed"
>
> I am using Masterthought plugin which reads this json file to create its
> interactive reports.

You could add a post-processing step (in Jenkins?) to filter the JSON
report before you feed it to Masterthought. This is the easiest way I
see to remove stack traces from the result.

On a side note...

I understand BAs not being interested in stack traces but failing
tests cannot possibly be part of your definition of done! In my world
BAs are involved at the beginning of a card (three amigos) and at the
end before the card is moved into the done column. Why would they need
to look at failing tests?

Regarding changing the step results, I suppose BAs are smart enough to
understand the difference between successful, failed, skipped and
pending. Did this requirement come from them?

> On Tuesday, 26 May 2015 01:06:21 UTC+5:30, Paolo Ambrosio wrote:
>>
>> On Mon, May 25, 2015 at 7:11 PM, AutomationQA
>> <shobhitg...@gmail.com> wrote:
>> > Hi All,
>> >
>> > I am using Cucumber JVM with JUnit having following plugin options
>> >
>> > plugin = {"html:target/cucumber" , "json:target/cucumber.json" },
>> >
>> > The cucumber.json file is created after the execution is completed
>> > whereas I
>> > need to update this json file at runtime to change the node values such
>> > as
>> > status and error description.
>> >
>> > Please let me know how can I access and modify this json file at
>> > runtime.
>>
>> Why you need to do it at runtime? It would be so much easier to
>> convert the json afterwards.
>>
>> If there is nothing you can do to avoid it, I suppose you could write
>> your own formatter. You can try and understand how they work by
>> looking at the existing formatters:
>>
>>
>> https://github.com/cucumber/cucumber-jvm/tree/master/core/src/main/java/cucumber/runtime/formatter
>>
>> > Thanks in advance.
>> >
>> > Regards
>> > Shobhit
>
> --
> Posting rules: http://cukes.info/posting-rules.html
> ---
> You received this message because you are subscribed to the Google Groups
> "Cukes" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cukes+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

AutomationQA

unread,
May 26, 2015, 3:23:00 AM5/26/15
to cu...@googlegroups.com
Though that's a valid point , but here BA's are involved in testing activities also so when we share the execution report , they prefer to have a cleaner reports rather than having technical details :-)

I will try to put the logic of updating the json file after the execution is over, but I would have preferred to have an interface which can update the json file at the runtime only.

Regards
Shobhit

Roberto Lo Giacco

unread,
May 26, 2015, 5:42:44 AM5/26/15
to cu...@googlegroups.com

Il giorno martedì 26 maggio 2015 09:23:00 UTC+2, AutomationQA ha scritto:
Though that's a valid point , but here BA's are involved in testing activities also so when we share the execution report , they prefer to have a cleaner reports rather than having technical details :-)

I will try to put the logic of updating the json file after the execution is over, but I would have preferred to have an interface which can update the json file at the runtime only.

If all you want to do is remove stuff from the report and you are looking for an HTML final format I would write a custom HTML page containing only what I want picked from the JSON file... I wouldn't alter the existing JSON removing information from there.
If you read the cucumber.json you obtain a JavaScript object, so you can iterate over it and manipulate the DOM to produce the report you need, with a custom appearance. The only problem I see is the browser not allowing to open a file, which means you'll have to publish the two files and access them through HTTP rather than FILE protocol... Does it make sense? 

Roberto
Reply all
Reply to author
Forward
0 new messages