Sunday 11 August 2019

java - How to log junit test run results to a database

We use junit for integration tests. The tests are being run in Eclipse and Jenkins.


Now i would like to log all junit test run results to a database for easy reporting (i want to log test class / method name, environment, duration and success).
I had thought about parsing the junit result xmls but to log it directly to a database sounds good to me, too. It sounds intrusive but also pretty elegant.


Normally we just annotate a test method with the @Test annotation and voila, we have our junit test method.


That means we have no additional framework around junit and i want to keep it that way. I fear that means that if i want to implement that kind of logging i will probably have to hack into junit.


Has anybody done so and can give advice if that works nicely? Maybe you have an idea on how/where to place the hook in junit. Or are there easier approaches to my problem?


Thanks!


edit:
To clarify, we already have junit test results of single test runs. You can get them out of eclipse (export junit result) or out of jenkins. Running our junit test suites in Jenkins also allows us to track test failure rates of test suites over time. It shows you a nice chart that tracks how many tests of passed over time. In each jenkins build you can see which tests passed, also in comparison to the last run.
We need a bit more. We want to be able to analyse the performance (duration) of certain testcases over time, over multiple runs, maybe also how they behave differently in different environments. Extract trends. Do some data mining.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...