'assertEquals()' called on array
Reports JUnit assertEquals()
calls with arguments of an array type. Such methods compare the arrays' identities instead of the arrays' contents. Array contents should be checked with the assertArrayEquals()
method.
Example:
@Test
public void testSort() {
int[] actual = {248, 496, 0, 56};
Arrays.sort(actual);
Assert.assertEquals(new int[] {0, 56, 248, 496}, actual);
}
After the quick-fix is applied:
@Test
public void testSort() {
int[] actual = {248, 496, 0, 56};
Arrays.sort(actual);
Assert.assertArrayEquals(new int[] {0, 56, 248, 496}, actual);
}
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
AssertEqualsCalledOnArray- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | JUnit, 243.23126 |
Last modified: 03 December 2024