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

Separate the Stack and The Error from a TestCase Failure #224

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

Conversation

mastrzyz
Copy link
Contributor

Currently a big problem is that we are only using the inner text of the Failure like so:

    <testcase classname="sanity_window_apps.ui.test.ts" name="Tab Test Sanity" time="33.061">
      <failure>Error: [Test] ❌ Unable to find element of type xpath</failure>
    </testcase>

With the code being like this: ie treating what's inside of the failure object as a pure string :

      testCase.testcase.push({
        [tagName]: stripAnsi(failure)
      });

This effectively makes no differentiation between the Stack trace of a Failure or the message.

While the JUNIT standard is loose, officially Azure Devops treats the inner text part of Failure as stack trace while the attribute message as the actual message


| Error message | /Testsuites/testsuite/testcase/failure.Attributes["message"].Value Or /Testsuites/testsuite/testcase/error.Attributes["message"].Value Or /Testsuites/testsuite/testcase/skipped.Attributes["message"].Value
 | Stack trace | /Testsuites/testsuite/testcase/failure.InnerText Or /Testsuites/testsuite/testcase/error.InnerText

So we would get the following back by changing that :

    <testcase classname="sanity_window_apps.ui.test.ts" name="Tab Test Sanity" time="33.061">
      <failure message="Error: [Test] ❌ Unable to find element of type xpath">    at Generator.next (&lt;anonymous&gt;)
    at C:\src\f\node_modules\tslib\tslib.js:116:75
    at new Promise (&lt;anonymous&gt;)</failure>
    </testcase>

@mastrzyz
Copy link
Contributor Author

@palmerj3 would like your thoughts, this PR isn't ready just this is a major possible change here.

@palmerj3
Copy link
Collaborator

I like that.

This makes a lot of sense to me. If you can stabilize this I'd be happy to take a look and merge.

@mastrzyz
Copy link
Contributor Author

mastrzyz commented Sep 26, 2022

I like that.

This makes a lot of sense to me. If you can stabilize this, I'd be happy to take a look and merge.

Thanks, so far I got the existing UT's fixed, working to see of any edge cases I might of missed..

@mastrzyz
Copy link
Contributor Author

@palmerj3 verified in our CI it works! we are able to see stack traces in our CI/CD system yay!.

But would like your eyes , in theory is this a major version change since the format may be different?

@mastrzyz
Copy link
Contributor Author

@palmerj3

2 similar comments
@mastrzyz
Copy link
Contributor Author

@palmerj3

@mastrzyz
Copy link
Contributor Author

mastrzyz commented Nov 2, 2022

@palmerj3

@palmerj3
Copy link
Collaborator

Sorry for the delay in reviewing. I was traveling for work and then was ill.

Looking more closely at this, I am worried it will generate invalid XML. Escape codes in XML won't pass many XML parsers.

There is a PR and related issue that are in direct conflict with this change. See #230

I would be more willing to add something like this if it wasn't on by default and had a configuration option users could utilize to enable it.

@mastrzyz
Copy link
Contributor Author

So if I understand correctly, the current worry is that adding this new information might cause the XML to not be valid since some people might have strange stack trace messages with escape characters or unicode.

I can push this under a config option but not sure how that PR conflicts with mine.

@palmerj3
Copy link
Collaborator

Perhaps start a thread over there and discuss

@ivailop
Copy link

ivailop commented Aug 15, 2023

Separation of error-message and stack-trace is the way many (if not most) JUnit reporters do. It would be nice if this reporter also follows the established convention...

Regarding the stack-trace, shouldn't you better wrap it in CDATA - that way there would not be any worry of breaking the XML? Notice the way suite.console (which could also contain unsafe characters) is handled...

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.

None yet

4 participants