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

Skipped tests are classified as passed #12

Closed
williamdenton opened this issue Nov 21, 2019 · 9 comments
Closed

Skipped tests are classified as passed #12

williamdenton opened this issue Nov 21, 2019 · 9 comments

Comments

@williamdenton
Copy link

there is no special handling for Outcome.Skipped so skipped tests appear as successful in xml output.

They need a <skipped/> element so tools like jenkins can recognise and classify the tests appropriately

if (result.Outcome == TestOutcome.Failed)
{
var failureBodySB = new StringBuilder();
if (this.FailureBodyFormatOption == FailureBodyFormat.Verbose)
{
failureBodySB.AppendLine(result.ErrorMessage);
// Stack trace included to mimic the normal test output
failureBodySB.AppendLine("Stack Trace:");
}
failureBodySB.AppendLine(result.ErrorStackTrace);
var failureElement = new XElement("failure", failureBodySB.ToString());
failureElement.SetAttributeValue("type", "failure"); // TODO are there failure types?
failureElement.SetAttributeValue("message", result.ErrorMessage);
testcaseElement.Add(failureElement);
}

@williamdenton
Copy link
Author

closest i could find to a spec for junit output for a test case:

/~https://github.com/behave/behave/blob/85bca4533ae4fb0cb27b65d04c5dd50355210395/etc/junit.xml/junit-4.xsd#L38-L53

    <xs:element name="testcase">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="skipped" minOccurs="0" maxOccurs="1"/>
                <xs:element ref="error" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="failure" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="system-out" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element ref="system-err" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required"/>
            <xs:attribute name="assertions" type="xs:string" use="optional"/>
            <xs:attribute name="time" type="xs:string" use="optional"/>
            <xs:attribute name="classname" type="xs:string" use="optional"/>
            <xs:attribute name="status" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>

@williamdenton
Copy link
Author

williamdenton commented Nov 21, 2019

for now im using /~https://github.com/spekt/xunit.testlogger with vstest then using /~https://github.com/gabrielweyer/xunit-to-junit to convert xunit to junit. This gives ideal output in jenkins, with nice test names and skipped results

@Siphonophora
Copy link
Collaborator

@williamdenton Thanks. I will take a look. I couldn't find a spec that included skipped, which is why I grouped skipped under passed.

@Siphonophora
Copy link
Collaborator

Siphonophora commented Feb 15, 2020

@williamdenton Apologies for the delay. The new pre-release package includes a resolution for this issue. If you have time to take a look and provide feedback, that would be great.

@williamdenton
Copy link
Author

Hi @Siphonophora , ive just come round to modifying my CI pipeline again and pulled in your package from myget. Works well! Thank you!

Is this in master/nuget yet? (it took me a long time to try it out)

Greatly appreciate you fixing this 👍

@Siphonophora
Copy link
Collaborator

@williamdenton I'm glad its work. Its not on nuget yet. @codito Can we go ahead and push the current version to nuget?

@codito
Copy link
Contributor

codito commented Apr 20, 2020

@williamdenton
Copy link
Author

williamdenton commented Apr 20, 2020

Thanks, once again i really appreciate you maintaining this for the community! (do you do release notes?)

@Siphonophora
Copy link
Collaborator

Siphonophora commented Apr 20, 2020

@williamdenton Yes, I will write up release notes here later today or tomorrow: /~https://github.com/spekt/junit.testlogger/releases

Edit: here is the update:
Resolved: /~https://github.com/spekt/junit.testlogger/releases/tag/v2.1.32

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

No branches or pull requests

3 participants