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?

Richard Slater
  • 6,313
  • 4
  • 53
  • 81
Charlie S
  • 4,366
  • 6
  • 59
  • 97

3 Answers3

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

Liron Yahdav
  • 10,152
  • 8
  • 68
  • 104
  • 1
    Any way to specify this through the CLI when using `-resultBundlePath` xcbuild param? So ideally successful test screenshots should be deleted while unsuccessful kept. – Alexandre G Aug 31 '18 at 03:28
  • You might be able to figure out the parameters by looking at the build log in Xcode after going through my instructions. – Liron Yahdav Aug 31 '18 at 05:13
  • 2
    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 needs – Alexandre G Aug 31 '18 at 07:28
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!

cakes88
  • 1,857
  • 5
  • 24
  • 33
  • 3
    Thanks Konnor. Anyway of doing this using the xcode UI rather than terminal commands? Mostly running tests that way currently. – Charlie S Mar 09 '16 at 09:43
  • 1
    @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 affect – cakes88 Mar 10 '16 at 00:13
  • 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? – Charlie S Mar 14 '16 at 10:12
  • @CharlieSeligman I added an answer that would resolve your issue: https://stackoverflow.com/a/48015499/62. You'd have to revert the change you made to the Derived Data setting first. – Liron Yahdav Dec 28 '17 at 23:09
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.

Charlie S
  • 4,366
  • 6
  • 59
  • 97