Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-1076

Dedicated rule-set space for unit tests

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1
    • Component/s: Coverage & Tests
    • Labels:
      None

      Description

      Even if some rule engine like PMD or Checkstyle has dedicated rules to analyse unit test source code, Sonar doesn't integrate those rules (http://pmd.sourceforge.net/rules/junit.html) and doesn't provide any feature to check the quality of unit test source code.

      Of course, most of the time the quality requirements on unit test source code are not the same than the quality requirements on main source code.

      here is an exemple of a rule set for unit test source code :

      • no if/else logic per unit-test
      • clear setup/excercise/assert order (no verify() before when() speaking of
        mockito)
      • disallow reflection to hack-test private methods

      Sonar should allow to activate some rules :

      • only on unit test source code
      • only on main source code
      • both on unit test and main source code

      I guess a new column must be added to the rules and active_rules tables to handle such options. Moreover, Sonar should be able to launch rule engines like PMD to analyse the unit test source code with a subset of all the rules contained in the quality profile of the project.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dgageot David Gageot
              Reporter:
              sellersj Jim Sellers
              Votes:
              46 Vote for this issue
              Watchers:
              30 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: