Recently, I configured fastlane for the first time to create screenshots and I encountered an interesting challenge, to run selective tests only. I want during running tests to create only screenshots and exclude other files from running tests.
I assume you followed this official tutorial.
Now you have at least two schemes, one for the main project and one for fastlane. In my case there are NBackGame and FastlaneScreenshot, as you might guess, the second one is created to make screenshots.
I have some UITests but I don’t want fastlane to run all UI Tests because not all files create screenshots. To make it even easier, I created a separate UITest file for screenshots. It also helps to remember when and where I create screenshots.
My UITests target files look like that:
There are 3 files to make tests for each view, 1 file helper imported from fastlane, and 1 file to make screenshots. The goal is to use these 3 files when I run tests and run this one with screenshots when I want to create new screenshots. By default, all files are used in both cases.
The challenge, for now, is that when I run UITests all files are executed. You can use flags like “only_testing” or “skip_testing” but I didn’t want to remember every time to add new files there when the app will be changed.
I found a solution to exclude files from the whole scheme.
First, select a scheme and click “Edit Schemeā¦“
Then on the left menu go to the “Test” and “Info” tab and expand your UITests.
Now you can exclude files you don’t want in your scheme. In the screenshot, you see there is only one file selected and it’s because the scheme for screenshots is selected.
In the main scheme, it’ll be the opposite.
If you’re wondering what’s this NBackGame, it’s my game for iOS, there is its website created by a friend of mine.