You are comparing a String
and a List<Object>
.
So you're using the method assertEquals(Object expected, Object actual);
Obviously a String
is not equals to a List<Object>
and hence the fail.
But since the String representation of the list is the same as you wrote, it hides you the result in the console because it uses this representation to show you the result of this test.
So you should compare the String representation of boths :
assertEquals("[23.0]", setSorteer.trimNumberSet(numSet).toString());
A better idea would be to compare two Lists directly, and not base your test on the String representations because they can change in the future and your test will fail :
assertEquals(Arrays.asList(23.0), setSorteer.trimNumberSet(numSet));
Also any reasons that you don't return a
List<Double>
in your method?
public List<Double> trimNumberSet(Double[] numSet) {
List<Double> trimmedNumberSet = new ArrayList<>();
...
return trimmedNumberSet;
}