I know that many Derby developers are relatively new to JUnit, and that it is
not always easy to spot potential issues in the test code, such as arguments to
assertEquals being in the wrong order.
I noticed that someone on the Apache Harmony project
(http://incubator.apache.org/harmony/) has created a tool for detecting
potential issues with JUnit test code. The tool is a perl script that can be
downloaded from
https://issues.apache.org/jira/browse/HARMONY-1960
I just tried the script on
trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi, and it
reported a few potential issues and suggestions for "best practice"
improvements, such as:
trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURTest.java
line 139:
assertTrue("Expected query '" + queryString + "' to fail", false);
should be fail (always true)
trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/URCoveringIndexTest.java
line 104:
assertTrue("Update should not produce any warnings ", w == null);
should use assertNull
trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/CharacterStreamsTest.java
line 454:
assertEquals("FAIL - wrong value on column " + col, null, value);
expected is null - should use assertNull
Although the above "issues" are pretty much harmless (and there may be false
positives among the results), I think this is a nice tool for anyone developing
Derby JUnit tests.
--
John