Groovy Documentation

Package groovy.org.codenarc.rule.junit

 

Class Summary
AssertionTrap Visits code searching for assert statements or assert.* method calls.
ChainedTestAstVisitor
ChainedTestRule A test method that invokes another test method is a chained test; the methods are dependent on one another.
CoupledTestCaseAstVisitor
CoupledTestCaseRule This rule finds test cases that are coupled to other test cases, either by invoking static methods on another test case or by creating instances of another test case.
JUnitAssertAlwaysFailsAstVisitor
JUnitAssertAlwaysFailsRule Rule that checks for JUnit assert() method calls with constant arguments such that the assertion always fails.
JUnitAssertAlwaysSucceedsAstVisitor
JUnitAssertAlwaysSucceedsRule Rule that checks for JUnit assert() method calls with constant arguments such that the assertion always succeeds.
JUnitFailWithoutMessageRule This rule detects JUnit calling the fail() method without an argument.
JUnitFailWithoutMessageRuleAstVisitor
JUnitPublicNonTestMethodAstVisitor
JUnitPublicNonTestMethodRule Rule that checks if a JUnit test class contains public methods other than:
  • Zero-argument methods with names starting with "test"
  • The setUp() and tearDown() methods
  • Methods annotated with @Test
  • Methods annotated with
    Before:
    and
    @After
  • Methods annotated with
    BeforeClass:
    and
    @AfterClass
Public, non-test methods on a test class violate conventional usage of test classes, and can be confusing.
JUnitSetUpCallsSuperAstVisitor
JUnitSetUpCallsSuperRule Rule that checks that if the JUnit setUp() method is defined, that it includes a call to super.setUp().
JUnitStyleAssertionsAstVisitor
JUnitStyleAssertionsRule This rule detects calling JUnit style assertions like assertEquals, assertTrue, assertFalse, assertNull, assertNotNull.
JUnitTearDownCallsSuperAstVisitor
JUnitTearDownCallsSuperRule Rule that checks that if the JUnit tearDown() method is defined, that it includes a call to super.tearDown().
JUnitTestMethodWithoutAssertAstVisitor
JUnitTestMethodWithoutAssertRule This rule searches for test methods that do not contain assert statements.
JUnitUnnecessarySetUpAstVisitor
JUnitUnnecessarySetUpRule Rule that checks for a JUnit setUp() method that only contains a call to super.setUp().
JUnitUnnecessaryTearDownAstVisitor
JUnitUnnecessaryTearDownRule Rule that checks for a JUnit tearDown() method that only contains a call to super.tearDown().
JUnitUtil Utility methods for JUnit rule classes.
SpockIgnoreRestUsedAstVisitor
SpockIgnoreRestUsedRule If Spock's
IgnoreRest:
on any method, all non-annotated test methods are not executed.
UnnecessaryFailAstVisitor
UnnecessaryFailRule In a unit test, catching an exception and immedietly calling Assert.fail() is pointless and hides the stack trace.
UseAssertEqualsInsteadOfAssertTrueAstVisitor
UseAssertEqualsInsteadOfAssertTrueRule This rule detects JUnit assertions in object equality.
UseAssertFalseInsteadOfNegationAstVisitor
UseAssertFalseInsteadOfNegationRule In unit tests, if a condition is expected to be false then there is no sense using assertTrue with the negation operator.
UseAssertNullInsteadOfAssertEqualsAstVisitor
UseAssertNullInsteadOfAssertEqualsRule This rule detects JUnit calling assertEquals where the first or second parameter is null.
UseAssertSameInsteadOfAssertTrueAstVisitor
UseAssertSameInsteadOfAssertTrueRule This rule detects JUnit calling assertTrue where the first or second parameter is an Object#is() call testing for reference equality.
UseAssertTrueInsteadOfAssertEqualsAstVisitor
UseAssertTrueInsteadOfAssertEqualsRule This rule detects JUnit calling assertEquals where the first parameter is a boolean.
UseAssertTrueInsteadOfNegationAstVisitor
UseAssertTrueInsteadOfNegationRule In unit tests, if a condition is expected to be true then there is no sense using assertFalse with the negation operator.
 


Groovy Documentation