damianszczepanik / cucumber-reporting

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

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

Open jit3pam opened 5 months ago

jit3pam commented 5 months ago

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)
)
JitendraSingh2TR commented 5 months ago

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

damianszczepanik commented 5 months ago

Share the official specification about this

jit3pam commented 5 months ago

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.

JitendraSingh2TR commented 5 months ago

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

damianszczepanik commented 5 months ago

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

jit3pam commented 5 months ago

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 commented 4 months ago

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.

damianszczepanik commented 4 months ago

We can talk about implementation after finding specification

jit3pam commented 3 days ago

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