I have an Azure DevOps pipeline to build test and archive a native iOS app, but I cannot see the test results or the code coverage report.
The PublishTestResults@2 has the following test Results Formats:
- JUnit
- NUnit
- VSTest
- XUnit
- CTest
But none of them are used from Xcode XCTests.
Is there a way to see the test results or the code coverage report? If yes, please show me the yaml file.
I have already tried on the yaml file:
- task: PublishTestResults@2
inputs:
testResultsFormat: JUnit
testResultsFiles: '**/*.xml'
searchFolder: '$(System.DefaultWorkingDirectory)/test-results/'
But it doesn’t work for Xcode XCTests.
Lex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
Test results
In Xcode@5 – Xcode v5 task, there is an option publishJUnitResults used to publish JUnit test results to the Azure Pipelines. It uses xcpretty
to format xcodebuild
output.
- task: Xcode@5
inputs:
actions: 'test'
configuration: '$(Configuration)'
sdk: '$(SDK)'
xcWorkspacePath: '$(path)'
scheme: '$(Scheme)'
xcodeVersion: '13'
packageApp: false
signingOption: 'auto'
useXcpretty: true
publishJUnitResults: true
testRunTitle: 'iOS Tests'
Code Coverage
To publish the Code Coverage reports generated by XCode to the Azure Pipeline, you can use the Slather third party tool.
To use this tool, install it first using the gem install slather
script. Then publish the code coverage report using the PublishCodeCoverageResults
task.
- script: gem install slather
displayName: 'Install Slather'
- script: slather coverage -x --scheme $(scheme) --workspace $(workspacePath) --output-directory $(coveragePath) $(projectPath)
displayName: 'Run slather to convert Code Coverage'
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: '$(coveragePath)/cobertura.xml'
See the details from this blog.