Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3578

Test methods should comply with a naming convention

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Rename this method to match the regular expression: yyyy
    • List of parameters:
      • Key : format
      • Description : Regular expression the test method names are checked against.
      • Default value : ^test[A-Z][a-zA-Z0-9]*$
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Covered Languages:
      Java
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Test Sources

      Description

      Shared naming conventions allow teams to collaborate efficiently. This rule raises an issue when a test method name does not match the provided regular expression.

      Noncompliant Code Example

      With the default value: ^test[A-Z][a-zA-Z0-9]*$

      @Test
      public void foo() {  // Noncompliant
        //...
      }
      

      Compliant Solution

      @Test
      public void testFoo() {
        // ...
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ann.campbell.2 Ann Campbell
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: