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

Provide a testable implementation of the issues API for unit tests

    XMLWordPrintable

    Details

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

      Description

      The goal of this ticket is to provide a default implementation of the classes involved in the creation of issues in the sonar-testing-harness module, suited for unit tests and assertions.

      As SonarQube 4.4 is going to become the next LTS version, the upgrade to its API will soon be possible. This is an excellent opportunity to provide a short-term fix, without having to depend on a full API redesign.

      The new issue API relies on complex chains of method calls to be able to create a single issue.

      Lots of different classes are involved in the process:

      • ResourcePerspectives
      • ActiveRule
      • Issuable
      • Issue
      • IssueBuilder

      Let's take the StyleCop plugin sensor as an example, which has 165 lines:
      https://github.com/SonarCommunity/sonar-stylecop/blob/a1db5b514ab84112b993e3c9d1f2eb25e8b4582c/src/main/java/org/sonar/plugins/stylecop/StyleCopSensor.java#L118

      The unit test class has 190 lines, and must mock the whole chain of calls:
      https://github.com/SonarCommunity/sonar-stylecop/blob/a1db5b514ab84112b993e3c9d1f2eb25e8b4582c/src/test/java/org/sonar/plugins/stylecop/StyleCopSensorTest.java

      Due to these testing difficulties, there currently is some resistance in migrating from Violation to Issue

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              henryju OLD - Julien HENRY
              Reporter:
              dinesh.bolkensteyn Dinesh Bolkensteyn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: