cucumber-reporting icon indicating copy to clipboard operation
cucumber-reporting copied to clipboard

Update Qualifiers in reports when cucumber json output has information on OS and devices

Open jit3pam opened this issue 1 year ago • 9 comments

After completion of tests, it is required of me to add OS and devices information to cucumber reports. I have a cucumber json output that already has a platform tag for every test feature.

At present, the qualifiers can be added to the reports to display this information.

For example:

"platform":"OS X, Big Sur, Chrome, latest"

However, Feature parser doesn't have any json property for processing this information.

Expected outcome:

  1. Feature parser should have a Json property called 'platform'. For example,
    @JsonProperty("platform")
    private String platform;
  1. Report parser could optionally read the platform property. For example,
feature.setQualifier(
    feature.getPlatform() != null && !feature.getPlatform().isEmpty() ?
    feature.getPlatform() : Objects.toString(configuration.getQualifier(jsonFileName), jsonFileName)
)

jit3pam avatar Jan 29 '24 07:01 jit3pam

@damianszczepanik please if you could share your thoughts on this.

JitendraSingh2TR avatar Feb 01 '24 08:02 JitendraSingh2TR

Share the official specification about this

damianszczepanik avatar Feb 03 '24 07:02 damianszczepanik

Hi @damianszczepanik Thank you for your reply.

I am very new to cucumber-reporting project. I am not aware of the information on specification of feature parser. Please if you could let me know the resources that I can refer to.

According to my knowledge, the third-party plugins can include the tags to the cucumber json outputs. In my project, I use browserstack sdk to run the tests and the information on platform is present in the cucumber json output. I also do not know whether adding information to feature in cucumber json outputs refer to a specification.

Moreover, I also created a fork https://github.com/jit3pam/cucumber-reporting to check my changes in order to complete an assigned work in my project.

If required I can also prepare a pull request based on our discussion. Your inputs in this regard will be very helpful.

jit3pam avatar Feb 04 '24 10:02 jit3pam

I checked the W3C Specifications at https://www.w3.org/TR/webdriver/#processing-capabilities

name equals "platformName" If value is not a string return an error with error code invalid argument. Otherwise, let deserialized be set to value.

The Java implementation https://github.com/SeleniumHQ/selenium/blob/b6b209602d544b769a0f4635022cf55a7b8f81b4/java/src/org/openqa/selenium/Capabilities.java#L35

@damianszczepanik @jit3pam

JitendraSingh2TR avatar Feb 14 '24 12:02 JitendraSingh2TR

This is webdriver specification and this implementation is based on cucumber bdd concept. Not all attributes - I believe - defined in driver goes to the cucumber result/output

damianszczepanik avatar Feb 14 '24 22:02 damianszczepanik

I found a related issue https://github.com/cucumber/cucumber-jvm/issues/1343.

cucumber-jvm-parallel-plugin

image

Points to Note

cucumber-jvm-parallel-plugin created files as required by cucumber-reporting, which determines the qualifiers based on the file names.

Now cucumber-jvm has inbuilt support for running test scenarios in parallel.

The feature map implementation

https://github.com/cucumber/cucumber-jvm/blob/edf09f1fbabf0a9bb2cb0d3abab59eb52875585f/cucumber-core/src/main/java/io/cucumber/core/plugin/JsonFormatter.java#L154C5-L179C6

jit3pam avatar Feb 17 '24 07:02 jit3pam

Hi @damianszczepanik,

I thought of a different approach.

Is it possible to annotate variable qualifier with @JsonProperty("platform")?

for example:

    @JsonProperty("platform")
    private String qualifier;

and then we could change the setQualifier method in the Feature class.

public void setQualifier(String qualifier) {
        if (getQualifier() != null){
            this.qualifier = getQualifier();
        }
        else {
            this.qualifier = qualifier;
        }
    }

I can submit a pull request with tests and an updated sample json file.

jit3pam avatar Feb 25 '24 09:02 jit3pam

We can talk about implementation after finding specification

damianszczepanik avatar Feb 25 '24 19:02 damianszczepanik

Guys, do we have any information on specification on cucumber bdd? where we can search for the same?

jit3pam avatar Jul 18 '24 05:07 jit3pam