serenity-bddcucumber-junitcucumber-serenity

Edit custom fields in summary report at runtime


I have a test project that tests an application that's constantly getting updated. As such, I'm asked quite frequently to run regression tests for it and to keep track of which report is for which version, I've added an "ApplicationVersion" custom field to my serenity-summary.html report.

This is defined in my serenity.properties file as such

report.customfield.ApplicationVersion=${ApplicationVersion}

I've also mentioned "ApplicationVersion" as a system property in my build.gradle file.

Due to the frequency of the tests, I want to set up my project so that it retrieves the application version automatically, and then overrides whatever value was present earlier.

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 or am I on a wild goose chase here? Any alternate way to store/update the ApplicationVersion variable, to facilitate this functionality, is also appreciated.


Solution

  • I received an answer from John Ferguson Smart over on the Serenity GitHub page. This functionality is supported for index reports, but not for serenity-summary reports

    Link to Question: Edit custom fields in summary report at runtime