Last updated: Apr 10, 2018 00:10
When executing an XCUITEST or XCTest test via the Gradle Plugin and the execution fails with error message "unexpectedly found nil while unwrapping an Optional value".
The UI Runner ipa file which includes your tests has a system variable with a value of "nil". When executing the tests from your local machine, the tests are successful as the test have access to the variables stored on your machine. However, when the test is exported and executed on the Perfecto device, these variables have a nil value and the tests fail with the error message.
Do not use system variables in your tests, use test variables or use hard coded values instead.