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: Add JUnit output format for test results #1508
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1508 +/- ##
==========================================
+ Coverage 53.68% 54.06% +0.38%
==========================================
Files 121 122 +1
Lines 13472 13571 +99
==========================================
+ Hits 7232 7337 +105
+ Misses 5618 5609 -9
- Partials 622 625 +3
|
Nice! Test suites have a - <testsuite name="company_test.yaml" description="CompanyTestSuite" errors="0" failures="0" skipped="4" tests="12">
+ <testsuite name="CompanyTestSuite" description="My company test" file="company_test.yaml" errors="0" failures="0" skipped="4" tests="12"> Even I think we can use steps to render the execution trace from |
a392d73
to
d96ced2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! There are a couple of small issues to fix:
- If the output format is set to
junit
, compile or lint errors don't get displayed. - I realise now that the traces require more work because we have to essentially define the schema for how to render them. Therefore, let's remove that feature from this PR. Being able to render the test failures and successes without traces is already a big improvement. We can add traces later in a different PR.
Just FYI, the reason why traces require more work is because of the following:
- The traces need to go inside the corresponding test case rather than the test suite.
- I think that the trace output is supposed to look (roughly) like the following. (We need to work out the correct schema first.)
<property="step[cerbos.resource.company.vdefault - rule-001]" value="activated">
<trace>
<condition><![CDATA[R.id == "test"]]></condition>
<action>read</action>
<policy>cerbos.resource.company.vdefault</policy>
<rule>rule-001</rule>
<result>true</result>
<outcome>activated</outcome>
</trace>
</property>
<property="step[cerbos.resource.company.vdefault - rule-002]" value="skipped">
<trace>
<action>read</action>
<policy>cerbos.resource.company.vdefault</policy>
<rule>rule-002</rule>
<outcome>skipped</outcome>
</trace>
</property>
997f719
to
44cdb67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure that the test output flag value defaults to the value of the output flag if the former is not explicitly set.
Regarding the problem of distinguishing why the command failed (lint, compile, or test) I think we can return different exit codes when the program terminates. You can override the default exit handler using kong.Exit
. So, the exit codes could be the following:
3
- Lint failure4
- Compile failure5
- Test failure
Finally, let's update the docs pages to include the new test-output
flag and describe how it works.
Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
d111f1e
to
08f7272
Compare
Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
References
https://github.com/gotestyourself/gotestsum/tree/main/internal/junitxml
https://github.com/testmoapp/junitxml
Example Output (
-ojunit
)Example Output (
--verbose -ojunit
)