SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • GroovyGroovy
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
Groovy

Groovy static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your GROOVY code

  • All rules 21
  • Bug5
  • Code Smell16
Filtered: 1 rule found
testing
    Impact
      Clean code attribute
        1. Test methods should contain assertions

           Code Smell

        Test methods should contain assertions

        intentionality - complete
        maintainability
        Code Smell
        • testing

        This rule raises an issue when a test method does not contain any assertion statements, calls to assertion methods, or use of framework-specific assertion blocks (such as Spock’s then:, expect:, or where: blocks). The rule does not apply to disabled tests or tests that delegate to helper methods containing assertions.

        Why is this an issue?

        How can I fix it?

        More Info

        Test methods without assertions are problematic for several reasons:

        First, they provide no actual validation of the code being tested. A test that executes code but doesn’t verify the results gives a false sense of security - it appears that the code is tested, but no actual verification occurs.

        Second, missing assertions often indicate incomplete test implementation. Developers may have written the setup code but forgotten to add the verification logic, leaving the test in an unfinished state.

        Third, such tests can hide real issues. If the tested code throws an exception, the test will fail, but if it completes without error, the test passes regardless of whether the behavior is correct.

        Finally, tests without assertions make it harder to understand what behavior is being verified, reducing the documentation value of the test suite.

        Exceptions

        The following patterns are considered valid and will not trigger this rule:

        • Tests using framework-specific assertion blocks (e.g., Spock’s then:, expect:, or where: blocks)
        • Tests explicitly marked as disabled (e.g., @Test(enabled=false) in TestNG)
        • Tests that delegate verification to helper methods that encapsulate assertions

        What is the potential impact?

        Tests without assertions provide no actual verification of code behavior, leading to false confidence in test coverage. This can allow bugs to go undetected and makes it difficult to catch regressions when code changes.

          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories

        © 2026 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use