When using xcresultparser 2.0.1 with -o xml output (SonarQube generic test execution format), some <file> elements have incorrect path attributes, and some <testCase> elements are missing the required duration attribute:
1. Source file paths instead of test file paths — test cases are attributed to the source file under test rather than the test file that contains them:
<file path="Sources/MyApp/SomeFeature/SomeClass.swift" configuration="Test Scheme Action">
<testCase name="testSomeBehavior()" duration="0"/>
<testCase name="testAnotherBehavior()" duration="0"/>
</file>
The tests actually live in Tests/MyAppTests/SomeFeature/SomeClassTests.swift, but the path resolves to the source file being tested.
2. Test plan/suite names instead of file paths — some entries use a display name rather than a file path:
<file path="MyFeature Tests" configuration="Test Scheme Action">
<testCase name="testSomeProperty()" duration="0"/>
</file>
3. Missing duration attribute on testCase elements — some test cases are emitted without the duration attribute:
<testCase name="testSomething()"/>
SonarQube's scanner (8.1+) requires duration on every testCase element. The error:
java.lang.IllegalStateException: Missing attribute "duration" in element "testCase" at line N
Issues 1 and 2 also cause SonarQube's parser to fail:
java.lang.IllegalStateException: Line N of report refers to a file which is not configured as a test file
Environment:
- xcresultparser 2.0.1
- Xcode 26
.xcresult bundle generated by xcodebuild test
Expected:
- All
<file path="..."> entries should reference the test file containing the test cases, not the source file under test or a test plan display name
- All
<testCase> elements should include a duration attribute
Note: This worked correctly in 1.9.4. The issues likely came from the 2.0.0 rewrite that replaced XCResultKit with direct xcresulttool parsing. It appears the parser is resolving the "subject under test" from the xcresult metadata rather than the test file location.
When using xcresultparser 2.0.1 with
-o xmloutput (SonarQube generic test execution format), some<file>elements have incorrectpathattributes, and some<testCase>elements are missing the requireddurationattribute:1. Source file paths instead of test file paths — test cases are attributed to the source file under test rather than the test file that contains them:
The tests actually live in
Tests/MyAppTests/SomeFeature/SomeClassTests.swift, but the path resolves to the source file being tested.2. Test plan/suite names instead of file paths — some entries use a display name rather than a file path:
3. Missing
durationattribute ontestCaseelements — some test cases are emitted without thedurationattribute:SonarQube's scanner (8.1+) requires
durationon everytestCaseelement. The error:Issues 1 and 2 also cause SonarQube's parser to fail:
Environment:
.xcresultbundle generated byxcodebuild testExpected:
<file path="...">entries should reference the test file containing the test cases, not the source file under test or a test plan display name<testCase>elements should include adurationattributeNote: This worked correctly in 1.9.4. The issues likely came from the 2.0.0 rewrite that replaced XCResultKit with direct xcresulttool parsing. It appears the parser is resolving the "subject under test" from the xcresult metadata rather than the test file location.