Shot icon indicating copy to clipboard operation
Shot copied to clipboard

How to emit json output instead of html

Open draganrakas opened this issue 3 years ago • 4 comments

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!

draganrakas avatar Jun 09 '21 13:06 draganrakas

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.

pedrovgs avatar Jul 01 '21 06:07 pedrovgs

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

SamCosta1 avatar Jul 01 '21 11:07 SamCosta1

@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).

SamCosta1 avatar Jan 11 '22 09:01 SamCosta1

Instead of adding different dictionaries for every screenshot, why just not add an array of screenshots with the execution result inside?

pedrovgs avatar Jan 24 '22 19:01 pedrovgs