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

feat: populate <skipped> message with last line of test output #158

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

marcuscaisey
Copy link

This PR sets the <skipped> node's message attribute to the last line of the output from the skipped test.

I've made this change as I came across an issue when trying to integrate this tool with https://github.com/thought-machine/please which only looks at the message attribute of the <skipped> node and not the containing text, so was outputting Skipped as the reason for each skipped test which isn't very helpful.

This seems more the correct behaviour imo since this is how JUnit outputs its XML report:

// AppTest.java
package com.marcuscaisey;

import org.junit.Test;
import org.junit.Ignore;

public class AppTest {
  @Test
  @Ignore("skip message")
  public void shouldBeSkipped() {
      throw new RuntimeException("should not get thrown");
  }
}
<!--TEST-com.marcuscaisey.AppTest.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="com.marcuscaisey.AppTest" time="0.013" tests="1" errors="0" skipped="1" failures="0">
  <properties>
  ...
  </properties>
  <testcase name="shouldBeSkipped" classname="com.marcuscaisey.AppTest" time="0">
    <skipped message="skip message"/>
  </testcase>
</testsuite>

I've left the remaining lines of test output in the text of the <skipped> node. I'm not sure whether it should just contain all of the output lines (or none). I just did it this way to not duplicate info between the message and node text. I don't expect this case to really come up tbh since logging before skipping a test seems a bit odd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant