Vijayakumar Kb
Vijayakumar Kb

Reputation: 135

How to attach screen shot to XCUITest report in Jenkins. Can only see screenshot if running through XCODE

How to attach screen shot to XCUITest report in Jenkins. Can only see screenshot if running through XCODE

Steps

  1. I have a job in Jenkins which builds and runs the XCUITest
  2. But after completing there is no option to see the screenshot of failed cases
  3. I used xcpretty to generate HTML type report, but there also screenshot is not displayed. it has a -screenshot attribute but that only accepts screenshot with a sepecified name. (like TestcaseName_Classname.jpg) But xcuitest takes screenshot with name 'screenshot_<>.jpg"

    Can anyone throw some information on this

Thanks

Upvotes: 4

Views: 1952

Answers (2)

max mazurkevych
max mazurkevych

Reputation: 141

You need to point attachment.name as here

func takeScreenshot() {
        let screenshot = XCUIScreen.main.screenshot()
        let attachment = XCTAttachment(screenshot: screenshot)
        attachment.lifetime = .deleteOnSuccess
        attachment.name = UITest.sharedInstance.testCase.name
        add(attachment)
    }

Upvotes: 0

nixtalker
nixtalker

Reputation: 48

Screenshot collection in xcpretty is broken as of now.

https://github.com/supermarin/xcpretty/issues/251

You may use xcsummary as a workaround.

https://github.com/supermarin/xcpretty/issues/251

Upvotes: 1

Related Questions