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

Test classes should comply with a naming convention

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Rename class "xxx" to match the regular expression: yyyy
    • List of parameters:
      Hide
      • Key : format
      • Description : Regular expression against which test class names are checked.
      • Default value : ^((Test|IT)[a-zA-Z0-9_]+|[A-Z][a-zA-Z0-9_]*(Test|Tests|TestCase|IT|ITCase))$
      Show
      Key : format Description : Regular expression against which test class names are checked. Default value : ^((Test|IT) [a-zA-Z0-9_] +| [A-Z] [a-zA-Z0-9_] *(Test|Tests|TestCase|IT|ITCase))$
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Targeted languages:
      C#
    • 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 class name does not match the provided regular expression.

      Noncompliant Code Example

      With the default value: ^((Test|IT)[a-zA-Z0-9_]+|[A-Z][a-zA-Z0-9_]*(Test|Tests|TestCase|IT|ITCase))$

      class Foo {  // Noncompliant
        @Test
        void check() {  }
      }
      
      class Bar {  // Noncompliant
        @Nested
        class PositiveCase {
          @Test
          void check() {  }
        }
      }
      

      Compliant Solution

      class FooTest {
        @Test
        void check() {  }
      }
      
      class BarIT {
        @Nested
        class PositiveCase {
          @Test
          void check() {  }
        }
      }
      

        Attachments

          Issue Links

          1.
          C# RSPEC-4607 Language-Specification Active Unassigned
          2.
          Java RSPEC-5971 Language-Specification Active Unassigned

            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: