Test method without assertions
Reports test methods that do not contain any assertions. Such methods may indicate either incomplete or weak test cases.
Example:
Configure the inspection:
Use the table to specify the combinations of fully qualified class name and method name regular expression that should qualify as assertions. Class names also match subclasses.
Use the 'assert' keyword is considered an assertion option to specify if the Java
assert
statements using theassert
keyword should be considered an assertion.Use the Ignore test methods which declare exceptions option to ignore the test methods that declare exceptions. This can be useful when you have tests that will throw an exception on failure and thus don't need any assertions.
Inspection options
Option | Type | Default |
---|---|---|
Assertion methods | Table | None |
Class Name | TableColumn | [org.junit.Assert, junit.framework.Assert, org.junit.jupiter.api.Assertions, org.assertj.core.api.Assertions, org.assertj.core.api.WithAssertions, com.google.common.truth.Truth, com.google.common.truth.Truth8, org.mockito.Mockito, org.mockito.InOrder, org.junit.rules.ExpectedException, org.hamcrest.MatcherAssert, mockit.Verifications, kotlin.PreconditionsKt__AssertionsJVMKt, kotlin.test.AssertionsKt__AssertionsKt, org.testng.Assert, org.testng.AssertJUnit] |
Method Name Regex | TableColumn | [assert.*|fail.*, assert.*|fail.*, assert.*|fail.*, assertThat, assertThat, assert.*, assert.*, verify.*, verify, expect.*, assertThat, Verifications, assert, assert.*|fail.*|expect, assert.*|fail.*|expect.*, assert.*|fail.*] |
'assert' keyword is considered an assertion | Checkbox | false |
Ignore test methods which declare exceptions | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |