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 marked as successful in junit output #9

Open
williamdenton opened this issue Nov 21, 2019 · 2 comments
Open

Skipped tests are marked as successful in junit output #9

williamdenton opened this issue Nov 21, 2019 · 2 comments

Comments

@williamdenton
Copy link

This block of code needs to handle the skipped case and emit a skipped element. Currently anything not Failed is considered successful.

private static XElement CreateTestCaseElement(TestResultInfo result)
{
var element = new XElement("testcase",
new XAttribute("classname", result.Type),
new XAttribute("name", result.Name),
new XAttribute("time", result.Time.TotalSeconds.ToString("N7", CultureInfo.InvariantCulture)));
if (result.Outcome == TestOutcome.Failed)
{
var failure = new XElement("error");
failure.SetAttributeValue("message", RemoveInvalidXmlChar(result.ErrorMessage));
failure.Value = RemoveInvalidXmlChar(result.ErrorStackTrace);
element.Add(failure);
}
return element;
}

some speculative code that might fix this:

     if (result.Outcome == TestOutcome.Skipped) 
     { 
         var skipped = new XElement("skipped");   
         element.Add(skipped); 
     } 
@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

if anyone else comes across this issue, take a look at this alternative spekt/junit.testlogger#12

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

No branches or pull requests

1 participant