Setting SNAPSHOT_ARTIFACTS in Test action
Hello, I've spent a while now attempting to get a custom directory for the failure images by using the SNAPSHOT_ARTIFACTS environment variable. I finally got it working, but ran into a slight hiccup, and I'm not sure if it's caused by the library or maybe some project or build settings on my end.
If I set SNAPSHOT_ARTIFACTS in the Test action, I get the following error: failed - You can’t save the file “X” because the volume is read only.
However, if I set SNAPSHOT_ARTIFACTS in the Run action, and then enable Use the Run action's arguments and environment variables, it works. But, unfortunately, this means I can't use my own arguments and environment variables in the Test action.
Ideally, I wouldn't have to use the Run action's arguments and environment variables in the Test action, so that I could set whatever additional arguments and environment variables I need.
Thanks @lewisgodowski for the Run action workaround, I can confirm it works by default, but unfortunately when using Test Plans, the Use the Run action's stuff feature becomes no longer available, so I'm stuck with the "read only" error and can't customize where failed snapshots go. The default location that's deep inside the Simulator's bowels is inconvenient to get to and slows down workflow.
I need to use Test Plans for reasons, so I'd really be grateful for either a fix or another workaround that's compatible with Test Plans.
Selecting my tests target in the "Expand Variables Based On" dropdown worked for me:
@tw-space testplans do have "Environment variables" in Configurations tab. Have you tried?
Also, I need prepend $(SOURCE_ROOT) e.g. SNAPSHOT_ARTIFACTS=$(SOURCE_ROOT)/__FailedSnapshots__.
Using SNAPSHOT_ARTIFACTS=__FailedSnapshots__ makes it try to write at the root directory file://..., which is of course read-only, and fails with error message: "You can’t save the file “XxxTests” because the volume is read only."
As mentioned in https://stackoverflow.com/a/69237460 it's also possible to prefix the variable name to pass it to the test directly.
With TEST_RUNNER_SNAPSHOT_ARTIFACTS = mypath I was able to store the artifacts in mypath without changing anything in the XCode GUI.