A demo for how to setup testing with fastlane in Swift.
This demo tests the uitest by screenshot with Fastlane.
Before you using this demo, install fastlane first.
See here to install fastlane.
After installed, create a project with some ui.
In this demo, we have two page, the first page(PageOneVC) and second page(PageTwoVC).
And having a button in PageOneVC, a label in PageTwoVC.
Just to let you known that they are not the same page.
- When we first enter the PageOneVC, the button will show "first_in".
- When tapping the button, it will go to PageTwoVC.
- Then tapping the back button on the navigatoin bar.
- And we back to PageOneVC, the button will show "viewWillAppear".
By knowning what we want to test, we can use the XCUIApplication, XCUIElementQuery and XCTAssert to test.
- Lanch app.
- Check the button named "first_in" and the button named "viewWillAppear" exist or not.
- Tap the button.
- Check back button exists or not.
- Tap back.
- Check the button named "first_in" and the button named "viewWillAppear" exist or not.
Initialize snapshot by seeing here.
Then run "fastlane snapshot".
Then you will see a html created in the path: ./project/screenshots/screenshots.html.
The html will look like this:
Run "fastlane scan", and it will automatically run all the tests in the project.
And you will see like this: