conor       01/02/20 05:29:43

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/junit Tag:
                        ANT_13_BRANCH JUnitTestRunner.java
  Log:
  Make Test runner's error handling more closely match that of the
  standard JUnit test runners
  
  Submitted by: Stephane Bailliez <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.1   +14 -7     
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  
  Index: JUnitTestRunner.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- JUnitTestRunner.java      2001/01/30 17:01:32     1.6
  +++ JUnitTestRunner.java      2001/02/20 13:29:40     1.6.2.1
  @@ -161,15 +161,22 @@
                   testClass = loader.loadClass(test.getName());
               }
               
  +            Method suiteMethod = null;
               try {
  -                Method suiteMethod= testClass.getMethod("suite", new 
Class[0]);
  -                suite = (Test)suiteMethod.invoke(null, new Class[0]);
  -            } catch(NoSuchMethodException e) {
  -            } catch(InvocationTargetException e) {
  -            } catch(IllegalAccessException e) {
  +                // check if there is a suite method
  +                suiteMethod= testClass.getMethod("suite", new Class[0]);
  +            } catch(Exception e) {
  +                // no appropriate suite method found. We don't report any
  +                // error here since it might be perfectly normal. We don't
  +                // know exactly what is the cause, but we're doing exactly
  +                // the same as JUnit TestRunner do. We swallow the 
exceptions.
               }
  -            
  -            if (suite == null) {
  +            if (suiteMethod != null){
  +                // if there is a suite method available, then try
  +                // to extract the suite from it. If there is an error
  +                // here it will be caught below and reported.
  +                suite = (Test)suiteMethod.invoke(null, new Class[0]);
  +            } else {
                   // try to extract a test suite automatically
                   // this will generate warnings if the class is no suitable 
Test
                   suite= new TestSuite(testClass);
  
  
  

Reply via email to