Menu

Sonar - test coverage

Testing
2013-04-10
2013-05-27
  • Jörg Dippel

    Jörg Dippel - 2013-04-10

    For wuerfelschach there is a good base of JUnit tests.

    I want to know what does 'good' mean in that context and what do tools tell me about code coverage. For that I take Jenkins, combined with Sonar and Maven. The configuration of Sonar is similar to https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut/maven/ut-maven-jacoco-runTests.

    First the JUnit test do not deliver a result because Maven expects a naming scheme for JUnit tests, thus the suites are named now to *Test.java.
    Then the GUI test are not running because the controller extends JFrame. This leads to a java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it.
    This is bad for Maven, but the main aspect is a base for automatic testing.

    But the basics JUnit tests are performing:
    Unit tests coverage 30,8%
    31,8% line coverage
    27,0% branch coverage

    jenkins-1.510
    Apache Maven 3.0.4
    sonar-3.5.1

     
  • Jörg Dippel

    Jörg Dippel - 2013-04-10

    After repairing the GUI tests the JUnit test coverage is better:

    Unit tests coverage 72,3%
    75,9% line coverage
    59,5% branch coverage

     
  • Huluvu424242

    Huluvu424242 - 2013-05-26

    To analyse junit test cases and code quality i have added a maven site. Now you can show the reports via maven site in html. You must set in the project.properties maven.test.failure.ignore=true and run maven via: mvn clean test site

    The current site i have attached. So we could increase the quality step by step. At first i would like stop the "KlammerMonster" see the pmd report. Should i start with it?

     
  • Jörg Dippel

    Jörg Dippel - 2013-05-27

    I like to discuss the results of quality checking but i disagree with the classification 'useless parentheses' or named as 'Klammermonster' - compound conditions and also the only return statement uses parentheses.

     

Anonymous
Anonymous

Add attachments
Cancel