How to add custom metrics to JUnit output

Hello,

i want to format result of my performance test as JUnit output. I found that k6 is able to make custom file format in handleSummary function. I tried it in my script and it generated output with thresholds if they were passed or not.

<?xml version="1.0"?>
<testsuites tests="1" failures="1">
<testsuite name="k6 thresholds" tests="1" failures="1">
<testcase name="http_req_duration{group:::GET /api/test}"><failure message="failed" /></testcase>
</testsuite >
</testsuites >

Is there any option how to generate JUnit output with another metrics (avg, median, percentiles, …) keep these thresholds (passed / failed) without creating XML file. I want to pass it as argument to python script.
Every API call is wrapped to group and there are set thresholds for these groups according to avg response time.

Thank you in advance.

Hi @matomajzlik,

can you clarify on what you expect, please? Do you want to generate a text file and pipe it to a python script? Maybe post an example of what you get and what you expect as a file content.

With the customSummary you have access to all the collected metrics and you can directly control what you want to write. Of course, JUnit function has some limits, and you might hit that but nothing prevent you from writing a custom function.

Thanks

Hi @codebien ,

i want to convert test summary into JUnit format without creating XML file

const JUNIT_OUTPUT = jUnit(data);

and then send this formatted output to python script as argument

console.log(exec.command("python", ["test.py", JUNIT_OUTPUT]));

This solution is working but is generating just thresholds - mentioned above. I want to include to this summary output more metrics like avg, median, etc.

Thank you.

Hi @matomajzlik,
Unfortunately this isn’t supported, you have to extend the current solution implementing a custom summary.

I hope it helps.