1 Aug 2012

Finding Long Running Unit Tests in Maven

Over the last few months my role at work has been to improve our continuous integration and deployment process. One of the major things that has been bugging me was the time it was taking to run unit tests on some of our projects.

So last night I thought I would have a crack and writing a simple script to list out the longest running Maven tests. I started writing this in BASH but thought that Python would be a better option. This is the first time I have written any Python so it was a fun experience. This was tested using Python 2.7.1 and surefire reports based on Maven 3.0.4.

After running the test phase of your Maven project, simply copy the script below into the target/surefire-reports directory. It scans all the XML files and orders the tests from longest running to shortest.

Some side notes about Python, what a fast language to pick up and start prototyping with. Within a couple of hours I went from having no experience with Python to a nice little script.

This script has gone on my GitHub account so if you find any bugs or improvements, make a post and I will update it.


No comments:

Post a Comment