nhojpatrick commented on a change in pull request #45:
URL: https://github.com/apache/commons-validator/pull/45#discussion_r506942291



##########
File path: 
src/test/java/org/apache/commons/validator/routines/DomainValidatorStartupTest.java
##########
@@ -35,24 +39,52 @@
 @RunWith( ClassLoaderPerTestRunner.class )
 public class DomainValidatorStartupTest {
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testUpdateBaseArrayCC() {
-        DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, new 
String[]{"com"});
+        // FIXME Simplification once upgraded to Java 1.8
+        final ThrowingRunnable testMethod = new ThrowingRunnable() {
+            public void run() {
+                DomainValidator.updateTLDOverride(ArrayType.COUNTRY_CODE_RO, 
new String[]{"com"});
+            }
+        };
+        final IllegalArgumentException thrown = 
assertThrows(IllegalArgumentException.class, testMethod);
+        assertThat(thrown.getMessage(), is(equalTo("Cannot update the table: 
COUNTRY_CODE_RO")));

Review comment:
       Why skip? It's a common conversation I always keep having... I just 
wondered your rational...
   
   My argument to alway checking the exception message is how do you know the 
test is failing as you are expecting it to fail?
   
   You write a test to check X, and it throws Y exception. If Z might also 
causes Y to be thrown, so how do you know your testing X? My view is if you 
skip checking the exception message then you might as well just delete the test.
   
   So Digester BeanPropertySetterRuleTestCase.testSetUnknownProperty according 
to the error messages and comments should produce an NoSuchMethodException, but 
currently is throws org.xml.sax.SAXException due to a code path meaning any non 
expected Exception is ignored.
   
   So this test is to check COUNTRY_CODE_RO, but if the code behind the test 
changes and IllegalArgumentException is still thrown, how do you know it's the 
correct exception for what you have setup?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to