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 th开发者_如何学Cem 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.
I'm not sure if this is helpful to you, but you can do various types of redirects of the output of JUnit Tests and even specify a format for test reports, which you could in turn store in a database to be able to access and mantain through time, for further analysis or even statistical purposes.
A guide with an explanation on how this can be achieved, suggesting HTML reports, can be found here: http://www.skill-guru.com/blog/2010/03/26/generating-junit-test-results-as-html-report/
I hope that helps.
精彩评论