Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit custom fields in summary report at runtime #3446

Closed
gem-sparshsondhi opened this issue Apr 19, 2024 · 6 comments
Closed

Edit custom fields in summary report at runtime #3446

gem-sparshsondhi opened this issue Apr 19, 2024 · 6 comments
Labels

Comments

@gem-sparshsondhi
Copy link

Hi!
Is it possible to update the values of the custom fields that are being used when generating the serenity-summary.html report?

My current project takes in a system property named "ApplicationVersion" through the VM Options, and adds the value passed to it to the serenity-summary report.

This is defined in my serenity.properties file as such

report.customfield.ApplicationVersion=${ApplicationVersion}

However, I would like to make it so that the value of this variable is fetched and updated dynamically.

So if my cmd arguments are something like

clean test aggregate reports -DApplicationVersion="1.0.0" ...

and the latest version is 1.0.1, the 1.0.0 is overridden with 1.0.1 and the summary report shows the same.

I've tried the following methods, but they don't seem to work. These were placed in the Runner file with JUnit's "Before" annotation

  1. System.setProperty("ApplicationVersion", newVersion);
    
  2. Serenity.getCurrentSession().getMetaData().put("ApplicationVersion", newVersion);
    
  3.  EnvironmentVariables.setProperty("ApplicationVersion", newVersion);
    

I had the initial value set to 1.0.0, and the value to update it with (currently hard coded) as 1.0.1.

However, in the serenity-summary.html report, the value remained as 1.0.0.

Is there a way to do this?

Same Query on Stack Overflow

@wakaleo
Copy link
Member

wakaleo commented Apr 21, 2024

@gem-sparshsondhi
Copy link
Author

@wakaleo This page doesn't tell me how to overwrite the values from the code.

According to my requirements, I would like the "ApplicationVersion" custom field to overwrite from 1.0.0 to 1.0.1 based solely on the code being executed, and not the values set before execution.

The value for ApplicationVersion can be fetched via an API call, but I can't figure out how I would overwrite the older value.

Here's a step by step breakdown of what I'm looking for:

Initial Command:
clean test aggregate reports -DApplicationVersion="1.0.0" ...

(ApplicationVersion = 1.0.0)

Begin Execution
API Call returns ApplicationVersion as 1.0.1
Update ApplicationVersion

(ApplicationVersion = 1.0.1)

Proceed with Tests
Finish Execution
Generate serenity-summary.html report with ApplicationVersion as 1.0.1 (i.e. updated value)

@gem-sparshsondhi
Copy link
Author

This would add data to the index report though, right?
I need it in the summary report

@wakaleo
Copy link
Member

wakaleo commented Apr 22, 2024

That is not currently supported but you are more than welcome to propose a PR to update the Thymeleaf template files in the serenity-single-page-report module to allow for this. Alternatively, if this is valuable for your company, you can always request a commercial support package (these start at as little as $395 per month so are very good value from a corporate perspective).

@gem-sparshsondhi
Copy link
Author

This is a use case specifically for my project and not a company-wide requirement, so it's unlikely that we'll get the package, but I'll look into proposing a PR
Thanks @wakaleo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants