In this tutorial, we will "create" some tests for an iOS application using XCTest testing framework.
The iOS application is quite simple: it contains one interactor and one controller.
The application has one interactor class.
Tests use XCTest framework and thus extend XCTestCase. The following class validates the arithmetic operations.
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 UnitTest-Calculator.xcodeproj/ -scheme UnitTest-Calculator -destination 'platform=iOS Simulator,OS=13.1,name=iPhone 8' 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)