In this tutorial, we will "create" some UI-based tests for an iOS application using XCTest testing framework along with XCUITest.
The iOS application is quite simple: it has just a button and a text that appears whenever clicking on it.
The application has one View Controller class.
The project contains two tests implemented in Swift: one named "testRecorded" (which is not an actual test case) and another, the real one, named "testRefactored".
Tests use XCTest framework and XCUITest to load the application and execute the UI-baed tests.
In order to run the tests from the command line or during CI, you can use
xcodebuild. By processing its output using
xcpretty, a JUnit XML can be generated (
build/reports/junit.xml, by default).
xcodebuild -project XCUITest101.xcodeproj/ -scheme XCUITest101 -destination 'platform=iOS Simulator,OS=13.1,name=iPhone 11 Pro Max' clean build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -r junit
If you're using Xcode, then you can also use it to write and run your tests (either all of them or just a specific one).
However, by default, this won't produce a JUnit XML report by itself which can, later on, be uploaded to Xray.
After running the tests and generating the JUnit XML report (e.g., junit.xml), it can be imported to Xray (either by the REST API or by using one of the CI plugins or through Import Execution Results action within the Test Execution).
A Test Execution will be created containing information about the executed scenarios.
Each test is mapped to a Generic Test in Jira, and the Generic Test Definition field contains the name of the class concatenated with the method name of the corresponding automated test.
The Execution Details of the Generic Test contains information about the "Test Suite" (as per JUnit format), which in this case corresponds to the fully-qualified name of the class holding the test.
In that case, you need to define a lane to run the tests and invoke the trainer plugin.
- xcpretty project seems to be not very active
- xcpretty has a known limitation that inhibits the processing of multiline error descriptions (only the header is imported as the log/output of the assertion)