How to turn off automatic screenshots on UI Testing (Xcode)
Asked Answered
E

3

11

I am running Xcode's UI Testing through Jenkins. Screenshots are taken at each step and so after running the suite for a while, the Mac uses up all its hard drive space. Does anyone know if you can switch off Xcode UI Testing's automatic screenshots, so less space is used?

Ekaterinodar answered 29/2, 2016 at 11:0 Comment(1)
Where are the screenshots saved?Petey
E
2

I didnt find a reliable way to deactivate screenshots, but the size taken up by them was removed by setting the following in jenkins:

Jenkins > Open Job > Configure > Build > Xcode > Advanced build settings > tick the box labelled 'Clean test reports'

This now keeps the test results in a far more manageable size and means I can constantly keep my test suites running in jenkins.

Hope this helps someone else.

Ekaterinodar answered 14/4, 2016 at 15:38 Comment(0)
W
9

Another way of doing this is configuring your Xcode Scheme to not take screenshots, by doing the following in Xcode:

  1. Edit Scheme (Cmd+Shift+<)
  2. Click on Test configuration on left side
  3. Click Options on top
  4. Uncheck "Capture screenshots automatically". Alternatively you can keep this checked but also check "Delete when each test succeeds" if you just want screenshots for failures.

Xcode Edit Scheme

Wheelwright answered 28/12, 2017 at 23:8 Comment(3)
Any way to specify this through the CLI when using -resultBundlePath xcbuild param? So ideally successful test screenshots should be deleted while unsuccessful kept.Adipose
You might be able to figure out the parameters by looking at the build log in Xcode after going through my instructions.Wheelwright
Thanks for the reply. I don't think Xcode builds using xcodebuild, but I've actually found that this seems to be the default. (Was sure it wasn't the case as had them for 1 successful test on server somehow and figured that's the norm) I've also found you can specify SystemAttachmentLifetime and UserAttachmentLifetime through the .xctestrun files so putting here in case anyone needsAdipose
F
5

I'm not sure how to turn off screen shots but you could put the screen shots to a location where they'd be deleted:

xcodebuild -workspace App.xcworkspace \
   -scheme "SchemeName" \
       -sdk iphonesimulator \
       -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.0'
       -derivedDataPath '/dev/null'
       test

Note the -derivedDataPath '/dev/null' which is where the screen shots will be going. This will put the screen shots to the null device, which is a special device which discards the information written to it.

Hope that helps, happy testing!

Ferretti answered 7/3, 2016 at 20:16 Comment(4)
Thanks Konnor. Anyway of doing this using the xcode UI rather than terminal commands? Mostly running tests that way currently.Ekaterinodar
@CharlieSeligman Choose Xcode > Preferences, and click Locations. There's a 'Derived Data' field there where you can set a customer location. Seems like you could just set that to /dev/null and have the same affectFerretti
This worked ok until I restarted the mac. Now getting 'Error cleaning build folder: Could not remove the build folder because of an unknown error'. Dont suppose anyone has a resolution for this?Ekaterinodar
@CharlieSeligman I added an answer that would resolve your issue: https://mcmap.net/q/411787/-how-to-turn-off-automatic-screenshots-on-ui-testing-xcode. You'd have to revert the change you made to the Derived Data setting first.Wheelwright
E
2

I didnt find a reliable way to deactivate screenshots, but the size taken up by them was removed by setting the following in jenkins:

Jenkins > Open Job > Configure > Build > Xcode > Advanced build settings > tick the box labelled 'Clean test reports'

This now keeps the test results in a far more manageable size and means I can constantly keep my test suites running in jenkins.

Hope this helps someone else.

Ekaterinodar answered 14/4, 2016 at 15:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.