-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Where to report the filename and line number in JUnit? #377
Comments
You are right, file name and line number is not part of any of the unofficial specs. However, some test tools use publish-unit-test-result-action/python/test/files/junit-xml/pytest/junit.fail.xml Lines 5 to 6 in 43acb3d
Note: this is not the line where an error (test failure) occurred but where the failing test is defined. |
@EnricoMi thanks very much for the reply. Unfortunately, as you mention, this is defined in the <?xml version="1.0" encoding="utf-8"?>
<testsuites tests="1" failures="5" errors="0" time="0.0">
<testsuite name="Compliance" tests="1" errors="0" failures="5" skipped="0" time="0">
<testcase name="Checkpatch" classname="Guidelines">
<failure message="subsys/bluetooth/host/hci_core.c:269 do not use C99 // comments" type="error">
C99_COMMENTS: do not use C99 // comments
File:subsys/bluetooth/host/hci_core.c
Line:269</failure>
<failure message="subsys/bluetooth/host/hci_core.c:270 that open brace { should be on the previous line" type="error">
OPEN_BRACE: that open brace { should be on the previous line
File:subsys/bluetooth/host/hci_core.c
Line:270</failure>
<failure message="subsys/bluetooth/host/hci_core.c:275 space prohibited between function name and open parenthesis '('" type="warning">
SPACING: space prohibited between function name and open parenthesis '('
File:subsys/bluetooth/host/hci_core.c
Line:275</failure>
</testcase>
</testsuite>
</testsuites> This is a usecase that seems to be supported by the JUnit/xunit spec. which then links to: or Which seems to allow multiple failures in a single testcase. |
@EnricoMi note that my goal is to reuse your action for one of the CI checks that is currently annotating manually, unlike others in the open source project I work on, which already use your action |
I think multiple failures should work with the action. When the messages are different, it should show multiple failures for the same testcase. Have you tried above file with the action? |
That's excellent to hear, but the problem is the filename/line number in each failure (hence the original question in this thread). I would need a way to convey to your action that the failure includes this "metadata" so it can place the GitHub annotations correctly as per GitHub's format. Each I store the failures in a "special" class that derives from and then print those as GitHub annotations:
No, I haven't yet, but it's great to know it should work, thanks! |
Nothing stops you from adding attributes to the
And then extend this section of junit.py: publish-unit-test-result-action/python/publish/junit.py Lines 219 to 240 in 71ca27c
It looks like this action "supports" multiple failures per testcase by picking the most severe, and from those the first only. So your use case (multiple results per test case) is not fully supported. What you want here is to create one
Finally,
has to use the Except for the last step, this looks required to fully support the spec. But I am hesitating to do the last bit as that is a bespoke JUnit XML spec. |
@carlescufi have you continued to work on this? |
Not yet @EnricoMi sorry. I will try to find some time for this during the summer and otherwise let you know. |
The JUnit spec doesn't mention file name and line number where an error occurred (eg. as attributes of
failure
).Since this action seems to display annotations inline with the PR files changed (i.e. the diff), how can one provide the file name and line number where an error was detected (for example by a linter program).
The text was updated successfully, but these errors were encountered: