Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-2927

S2699 Generalize matching and add a parameter to configure custom Assertion Frameworks

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.11
    • Component/s: Rules
    • Labels:
      None

      Description

      S2699 is already supporting a huge quantity of Assertion Frameworks (see RSPEC-2699) but:

      • new Assertion Frameworks are becoming popular every year and developers see FPs issues while they are using assertions
      • companies are creating their own Assertion Framework and S2699 is not aware of them

      For these reasons, S2699 should be generalized so that any method found in test cases that have a name following this pattern (assert|verify|fail|should|check|expect).* should be considered as assertions.

      Furthermore, it should be enhanced to support a parameter allowing a user to configure with wildcard style custom Assertion Frameworks method.
      As an example, let's take this case: https://groups.google.com/forum/#!topic/sonarqube/Mznxgg5Ek-c:

      Parameter: customAssertionMethods
      Configuration: com.company.CompareToTester#testCompare*, CustomAssert#assert* 
      

      Configuration value should comply with following format <FullyQualifiedClassName>#<methodPattern>.

      If in a test method, com.company.CompareToTester.testCompareTo(...) or com.company.CompareToTester.testCompareWith(...) or customAssert.assertTrue(...) or customAssert.assertWhatever(...) are used, S2699 will not raise an issue.

      TODO: update RSPEC-2699 while implementing this ticket

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              christophe.zurn Christophe Zurn
              Reporter:
              alexandre.gigleux Alexandre Gigleux
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: