Shot
Shot copied to clipboard
How to emit json output instead of html
Hi,
We are running Karumi Shot tests with ./gradlew executeScreenshotTests
and would like a more parseable way to postprocess these results. Is there a way (maybe a CLI arg) to emit a json output instead of an html?
I scanned the readme and didn't notice anything related, but saw some Json parsing related code, so I thought I'd ask the team here before parsing HTML.
Thanks!
Thanks for reporting @draganrakas 😃 If any external contributor would like to take this one, is more than welcome. Please, before start coding discuss the implementation details here.
I also think this would be really useful, I resorted to just ignoring Shot's report and just generating my own json output based on the file structure. In hindsight it would have been better to actually update the plugin
@pedrovgs I think I should have some time to pick things up. My proposed solution will involve passing a commandline argument to specify which output formats should be produced (defaulting to HTML only for backward compatibility).
Then I'm thinking it'll spit something out in the following format
{
"deleted": [
{
"testClass": "...",
"testName": "...",
"originalScreenshot": "./images/recorded/...."
}
],
"new": [
{
"testClass": "...",
"testName": "...",
"newScreenshot": "./images/recorded/...."
}
],
"modified": [
{
"testClass": "...",
"testName": "...",
"originalScreenshot": "./images/recorded/....",
"newScreenshot": "./images/....",
"diff": "./...."
}
],
"resized": [
{
"testClass": "...",
"testName": "...",
"originalScreenshot": "./images/recorded/....",
"newScreenshot": "./images/...."
}
]
}
This will be generated in a JSONExecutionReporter
class alongside the current reporters. (I think I'll also need to tweak the ScreenshotsComparator
in order to spit out results for new screenshots too).
Instead of adding different dictionaries for every screenshot, why just not add an array of screenshots with the execution result inside?