facebookarchive / ios-snapshot-test-case

Snapshot view unit tests for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pass IMAGE_DIFF_DIR to xcodebuild

jakunico opened this issue · comments

Hello everyone,

Our snapshot tests are failing on CI for some reason so we want to store the diff images in a special directory to see what's going on.

The problem is that we are being unable to pass in the IMAGE_DIFF_DIR to xcodebuild so it's read by FBSnapshotTestCase on:

folderPath = @(getenv("IMAGE_DIFF_DIR"));

We've tried setting it as an environment variable and then executing xcodebuild with no luck:

$ export IMAGE_DIFF_DIR="/some/directory/"
$ xcodebuild commands_redacted

I read somewhere that xcodebuild ignores environment variables and you have to manually pass them but it didn't work either:

$ xcodebuild commands_redacted IMAGE_DIFF_DIR="/some/directory/"

How can I specify this?

Thanks in advance!

Little update:

The snapshots were failing because the device list in our CI service (circleCI) were updated. We were specifying iOS 9.3 simulator in our xcodebuild which is no longer available. After passing in the updated simulator UUID tests started to pass again.

I was able to achieve what I wanted originally by editing the scheme and adding the environment variable there as described on the README. We originally wanted to define this variable in CI only and this solution requires us to enable/disable it manually. We're okay with this as CI snapshots don't fail often but it'd be nice to find a way to pass in this variable through xcodebuild command.