Examples for the UIUTest test framework at: https://github.com/nallick/UIUTest
Automated tests for a user interface are typically performed in a separate process from the app, where they can be slow, brittle and complex. With appropriate support, many of these tests are better executed within the app as unit tests, where they’re easier and faster. UIUTest is a unit test library written in Swift for iOS, which allows many of the tests typically implemented as user interface tests with XCUIApplication to be written as unit tests within the application.