Tweak assertion definition to avoid false positive with modern JUnit5 / AssertJ
This commit is contained in:
1 parent
0b6c0594f1
commit
065da32b19
2 files changed
+19
-1
No files matched your search
+2
-1
@@ -162,7 +162,8 @@ public class JUnitTestsShouldIncludeAssertRule extends AbstractJUnitRule {
|
||||
private boolean isAssertOrFailStatement(ASTStatementExpression expression) {
|
||||
String img = getMethodCallNameOrNull(expression);
|
||||
return img != null && (img.startsWith("assert") || img.startsWith("fail")
|
||||
|| img.startsWith("Assert.assert") || img.startsWith("Assert.fail"));
|
||||
|| img.startsWith("Assert.assert") || img.startsWith("Assert.fail")
|
||||
|| img.startsWith("Assertions.assert") || img.startsWith("Assertions.fail"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
@@ -529,6 +529,23 @@ public class FooTest extends TestCase {
|
||||
public void test2() {
|
||||
assertThat("doesn't matter", null, Matchers.nullValue());
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>AssertJ and JUnit5 ?</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class JUnit5AssertJTest {
|
||||
|
||||
@Test
|
||||
void check() {
|
||||
Assertions.assertThat("FOO").isNotNull();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
Reference in new issue
Block a user