#1323 False positive case of UseAssertTrueInsteadOfAssertEquals

This commit is contained in:
Andreas Dangel
2015-03-26 20:25:19 +01:00
parent 65c2493ec7
commit e46bea857a
3 changed files with 22 additions and 2 deletions

View File

@ -414,7 +414,7 @@ When asserting a value is the same as a boolean literal, use assertTrue/assertFa
<property name="xpath">
<value>
<![CDATA[
//PrimaryExpression[PrimaryPrefix/Name[@Image = 'assertEquals']][PrimarySuffix/Arguments/ArgumentList//Expression/PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral]
//PrimaryExpression[PrimaryPrefix/Name[@Image = 'assertEquals']][PrimarySuffix/Arguments/ArgumentList/Expression/PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral]
]]>
</value>
</property>

View File

@ -19,7 +19,7 @@
<description><![CDATA[
JUnit Test contains assertEquals on boolean literal
]]></description>
<expected-problems>4</expected-problems>
<expected-problems>5</expected-problems>
<code><![CDATA[
public class MyTestCase extends TestCase {
public void testMyCaseWithAssertEqualsOnBoolean() {
@ -28,8 +28,27 @@
assertEquals("myVar is true", myVar, true);
assertEquals("myVar is true", false, myVar);
assertEquals("myVar is true", myVar, false);
assertEquals(true, myVar);
}
}
]]></code>
</test-code>
<test-code>
<description>#1323 False positive case of UseAssertTrueInsteadOfAssertEquals</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
package com.groupon.mostest.refractor;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
public class TestWithAssertEquals {
@Test
public void testMethodWithBooleanParam() {
assertEquals(methodWithBooleanParam(true), "a String value", "they should be equal!");
}
public String methodWithBooleanParam(boolean param) {
return "a String value";
}
}
]]></code>
</test-code>
</test-data>