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

new function that generates junit xml for checks #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeevananthank
Copy link

@jeevananthank jeevananthank commented Apr 17, 2021

Background:

k6-to-junit was used to generate junit XML files for the checks with names matching the regex. Refer comment. k6 now has the support of generating junit XML report from version v0.30.0.

Issue:

For functional automated tests using k6, it would be very helpful to report each check in the test script, as a test case in a junit format enabling reporting in the CI build pipelines. And existing jUnit does not solve the purpose of having a check as a test case.

Solution:

added a new version of k6-summary exporting a new function: jUnitForChecks which returns a string in the format of junit xml string where each passed check is considered as a passed test case and failed check as a failed test case.

Note: this is considered only when using for automated functional regression test where the k6 test script is run with 1 user and 1 iteration.
Note: the name of the new function can be discussed 😄 and i have not added tests 😉 since there was no existing tests for jUnit.

Think this will be helpful for many and moving one step towards k6's goal of using it across different types of tests. 😎

Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Reviewing changes in the current jslib format is a bit unwieldy, so we're probably going to make a separate repo for the summary library, similar to how we have one for the httpx one (https://github.com/k6io/k6-jslib-httpx) soon and we'd just use this repo for the distributions.

}
return (
`<?xml version="1.0" encoding="UTF-8" ?>\n<testsuites tests="${cases.length}" ` +
`failures="${failures}\" time="${time}">\n` +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this seems wrong. According to https://llg.cubic.org/docs/junit/, this should be

Time taken (in seconds) to execute the tests in the suite

We don't have that data readily available in handleSummary() yet, though we could easily add it (e.g. in grafana/k6#1975).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did not find anything closer than iteration_duration in the summary.json to find the time taken to execute the tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... 😞 We can correct that in k6 v0.33.0, since I imagine it will be useful for other things as well. I added a note about it in grafana/k6#1975 (comment)

the old logic did not work on batch requests with checks on all the responses.
@na--
Copy link
Member

na-- commented May 19, 2021

Sorry for leaving you hanging for a while here... 😅 Here are some updates!

Yesterday we merged this PR in k6: grafana/k6#1975. Among a lot of other changes, it adds testRunDurationMs to the data.state we pass to handleSummary(): grafana/k6@580b054. This should will be released in k6 v0.33.0 around the end of June and should allow you to more accurately get the time.

I already mentioned that in my previous comment, but we'll probably also going to make a separate GitHub repo for the JS summary functions, similar to how we have one for the httpx one (https://github.com/k6io/k6-jslib-httpx) before we release k6 v0.33.0. Then we'd ask you to make the PR there and we'd just use this repo for the versioned distribution. That way PRs will be much easier to review.

@CLAassistant
Copy link

CLAassistant commented Jun 15, 2022

CLA assistant check
All committers have signed the CLA.

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.

3 participants