-
Bug
-
Resolution: Fixed
-
Normal
-
None
-
2.0.0
-
None
We expect that the following method calling should make a test case failed, but it doesn't.
verifyEquals("1", null)
Root Cause:
The verifyEquals() finally will call assertEquals(). In assertEquals, it doesn't consider the above case. (s1 is String, s2 is null), hence it won't fail a test case.
public class ZKSeleneseTestBase{ /** Like JUnit's Assert.assertEquals, but knows how to compare string arrays */ public static void assertEquals(String message, Object s1, Object s2) { if (s1 instanceof String && s2 instanceof String) { assertEquals((String)s1, (String)s2); } else if (s1 instanceof String && s2 instanceof String[]) { assertEquals((String)s1, (String[])s2); } else if (s1 instanceof String && s2 instanceof Number) { assertEquals((String)s1, ((Number)s2).toString()); } else { if (s1 instanceof String[] && s2 instanceof String[]) { String[] sa1 = (String[]) s1; String[] sa2 = (String[]) s2; if (sa1.length!=sa2.length) { if (message != null) throw new Error(message + "\nExpected " + sa1 + " but saw " + sa2); else throw new Error("Expected " + sa1 + " but saw " + sa2); } for (int j = 0; j < sa1.length; j++) { assertEquals(sa1[j], sa2[j]); } } } } }