Use assertSame instead of assertEquals where possible. #1555

Fixes `AssertEqualsMayBeAssertSame` inspection violation in test code.

Description:
>Reports any calls to org.junit.Assert.assertEquals() or junit.framework.Assert.assertEquals() which can be replaced with an equivalent call to assertSame(). This is possible when the arguments are instances of a final class which does not override the equals() method.
This commit is contained in:
Michal Kordas 2015-08-16 22:56:02 +02:00 committed by Roman Ivanov
parent de8f91ad67
commit 4074ab454e
1 changed files with 3 additions and 2 deletions

View File

@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle;
import static com.puppycrawl.tools.checkstyle.TestUtils.assertUtilsClassHasPrivateConstructor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -144,7 +145,7 @@ public class UtilsTest {
fail();
}
catch (IllegalStateException expected) {
assertEquals(NoSuchMethodException.class, expected.getCause().getClass());
assertSame(NoSuchMethodException.class, expected.getCause().getClass());
}
}
@ -167,7 +168,7 @@ public class UtilsTest {
fail();
}
catch (IllegalStateException expected) {
assertEquals(InstantiationException.class, expected.getCause().getClass());
assertSame(InstantiationException.class, expected.getCause().getClass());
}
}