Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skipped test tracking to JUnit output. #549

Merged
merged 1 commit into from
Jul 18, 2024
Merged

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jul 18, 2024

This PR adds skipped test reporting to our JUnit XML output. For example, given this test:

@Test(.disabled("Because I said so"))
func f() {}

The XML output would be, approximately:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="TestResults" errors="0" tests="1" failures="0" skipped="1" time="12345.0">
    <testcase classname="MyTests" name="f()" time="12344.0">
      <skipped>Because I said so</skipped>
    </testcase>
  </testsuite>
</testsuites>

See also swiftlang/swift-package-manager#7383 which asks for this for XCTest.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR adds skipped test reporting to our JUnit XML output. For example, given
this test:

```swift
@test(.disabled("Because I said so"))
func f() {}
```

The XML output would be, approximately:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="TestResults" errors="0" tests="1" failures="0" skipped="1" time="12345.0">
    <testcase classname="MyTests" name="f()" time="12344.0">
      <skipped>Because I said so</skipped>
    </testcase>
  </testsuite>
</testsuites>
```

See also swiftlang/swift-package-manager#7383 which
asks for this for XCTest.
@grynspan grynspan added enhancement New feature or request swiftpm-integration Swift Package Manager integration tools integration Integration of swift-testing into tools/IDEs labels Jul 18, 2024
@grynspan grynspan self-assigned this Jul 18, 2024
@grynspan
Copy link
Contributor Author

@swift-ci please test

@briancroom
Copy link
Contributor

Ah nice, thanks!

@grynspan grynspan merged commit 133d65e into main Jul 18, 2024
3 checks passed
@grynspan grynspan deleted the jgrynspan/junit-skipped branch July 18, 2024 21:46
@@ -183,14 +209,19 @@ extension Event.JUnitXMLRecorder {
///
/// - Returns: `character`, or a string containing its escaped form.
private static func _escapeForXML(_ character: Character) -> String {
if character == #"""# {
switch character {
Copy link

@jakepetroules jakepetroules Jul 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> isn't required to be escaped in XML attributes, but & definitely is. Could you add that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna leave > out of pedantry, but yeah I'll add &.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request swiftpm-integration Swift Package Manager integration tools integration Integration of swift-testing into tools/IDEs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants