You can solve your problem, but not with junitxml.
You can use pytest-harvest for this. Just install it and you can directly use the predefined appliances:
import random def test_val(results_bag): value = random.random()
Productivity
>>> pytest -s -v ============================= test session starts ============================= collecting ... collected 2 items tmp.py::test_val PASSED tmp.py::test_synthesis 'module_results_df' dataframe: status duration_ms value test_id test_val passed 0.999928 0.443547 PASSED ========================== 2 passed in 1.08 seconds ===========================
Then you can write the report to a separate file (requiring the junit xml file to be combined with you). Note that you do not need to write the above in the test, you can do this using any of the pytest hooks (either where you have access to the above devices, or to the pytest request.session object).
See the documentation for details.
Finally, if you also want to use parameters, fixtures, steps ... you can look at this sample data performance test.
Incidentally, I am the author;)
source share