Add tests UseAssertEqualsInsteadOfAssertTrue,UseAssertNullInsteadOfAssertTrue,UseAssertSameInsteadOfAssertTrue,UnnecessaryBooleanAssertion (https://github.com/pmd/pmd/issues/940)

This commit is contained in:
Alex Shesterov committed 2018-08-06 09:25:49 +00:00
1 parent 2dbb332f00
commit fadbbbba02
5 files changed
+131

No files matched your search

@@ -3074,6 +3074,9 @@ UnaryExpressionNotPlusMinus[@Image='!']
[ancestor::ClassOrInterfaceDeclaration[//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]
or //MarkerAnnotation/Name[
pmd-java:typeIs('org.junit.Test')
or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
]
]]]]>
</value>
@@ -70,6 +70,38 @@ public class Foo {
public void test1() {
assertTrue(a.equals(b));
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit5 - @Test
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@Test
public void test1() {
assertTrue(a.equals(b));
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit5 - @RepeatedTest
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.RepeatedTest;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@RepeatedTest(2)
public void test1() {
assertTrue(a.equals(b));
}
}
]]></code>
</test-code>
@@ -70,6 +70,38 @@ public class Foo {
public void test1() {
assertTrue(a==null);
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit 5 - assertTrue with null - @Test
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@Test
public void test1() {
assertTrue(a==null);
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit 5 - assertTrue with null - @RepeatedTest
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.RepeatedTest;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@RepeatedTest(2)
public void test1() {
assertTrue(a==null);
}
}
]]></code>
</test-code>
@@ -113,6 +113,38 @@ public class Foo {
public void test1() {
assertTrue(a==b);
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit 5 - assert true a == b - @Test
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@Test
public void test1() {
assertTrue(a==b);
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit 5 - assert true a == b - @RepeatedTest
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.RepeatedTest;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@RepeatedTest(2)
public void test1() {
assertTrue(a==b);
}
}
]]></code>
</test-code>
@@ -115,6 +115,38 @@ public class Foo {
void bar() {
assertTrue(true);
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit 5 - failure case - @Test
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@Test
void bar() {
assertTrue(true);
}
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
JUnit 5 - failure case - @RepeatedTest
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.RepeatedTest;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class Foo {
@RepeatedTest(2)
void bar() {
assertTrue(true);
}
}
]]></code>
</test-code>