iOS native app automation testing
Last updated
Last updated
Appfigurate can change the configuration of an iOS app being automation tested using XCTestCase
.
An example UI testing bundle AppfigurateExampleUITests
is available in both and GitHub repositories. To test, ensure AppfigurateExample (ObjC/Swift iOS)
is selected as the scheme, then long tap the run button to show more options and tap Test
(⌘U).
Tap on your subclass in the project navigator. In File inspector ‣ Target membership, tick on your UI testing bundle.
In your subclass, confirm that your method returns YES
/true
when running automation tests. (Test schemes are by default run with a DEBUG build).
When the configuration is applied to the application on launch, the standard Appfigurate 'Configuration applied' alert is displayed. It is recommended you add an UIInterruptionMonitor
to your XCTestCase
to automatically dismiss this alert. A good place to do this in the setUp
method.
Set the properties required to be applied to your app to allow it to be tested correctly.
Launch your app.
Appfigurate allows you to invoke functionality in the app under test, at runtime, from your XCTestCase
. Example use cases:
Setting mocked HTTP responses for HTTP requests in the app.
Share mocked objects between the XCTestCase
and app.
Read and set the internal state of the app.
Get an instance of your subclass in your XCTestCase
. A good place to do this in the setUp
method.
Apply the result of method to XCUIApplication launchArguments
property.
Once your app is launched, the configuration you set in will be applied before executing each test case.
See also and methods of .
You can apply configuration to the app after it has launched using the , and methods of . You can read the configuration from the app under test using the method.
Under the hood, the , , and methods use the and functions introduced in the .
Use the function in the app under test to declare a callback. The callback will be invoked anytime a message is received from the XCTestCase
. Best practice is to wrap the function in #if DEBUG
to ensure it's not included in an App Store build.
Use the function in your XCTestCase
to send a message and wait for a reply from the app under test.
The and is compatible with both iOS Simulators and physical iOS devices.
The plist
parameter accepts any object that is , or nil
. This also applies to the result returned from . The size of the property list once serialized, must be less than 65535 bytes, otherwise an will be thrown from the XCTestCase
. In practice, keep your property lists to just a few hundred bytes. Larger property lists will result in significant transmission time (tens of seconds).