Search code examples
sonarqubeexecution-timesurefire

Sonar: Execution time history of single test


TXTFIT = test execution time for individual test

Hello,

I'm using Sonar to analyze my Maven Java Project. I'm testing with JUnit and generating reports on the test execution time with the Maven Surefire plugin.
In my Sonar I can see the test execution time and drill down to see how long each individual test took. In the time machine I can only compare the overall test execution time between two releases.
What I want is to see how the TXTFIT changed from the last version.
For example:
In version 1.0 of my software the htmlParserTest() takes 1sec to complete. In version 1.1 I add a whole bunch of test (so the overall execution time is going the be way longer) but also the htmlParserTest() suddenly takes 2secs, I want to be notified "Hey mate, the htmlParserTest() takes twice as long as it used to. You should take a look at it".

What I'm currently struggling to find out:

  1. How exactly do the TXTFIT get from the surefire xml report into sonar?
    I'm currently looking at AbstractSurefireParser.java but I'm not sure if that's actually the default surefire plugin.
    I was looking at 5 year old stuff. I'm currently checking out this. Still have no idea, where Sonar is getting the TXTFIT from and how or where it is connecting it to the Source Files.
  2. Can I find the TXTFIT in the Sonar DB?
    I'm looking at the local DB from my test Sonar with DBVisualizer and I don't really know where to look. The SNAPSHOT_DATA doesn't seem like it's readable by humans.
  3. Are the TXTFIT even saved in the DB?
    Depending on this I have to write a Sensor that actually saves them or a widget that simply shows them on the dashboard

Any help is very much appreciated!


Solution

  • The web service api/tests/* introduced in version 5.2 allows to get this information. Example: http://nemo.sonarqube.org/api/tests/list?testFileUuid=8e3347d5-8b17-45ac-a6b0-45df2b54cd3c