bodewig     2003/03/28 04:20:51

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs/optional/junit
                        XMLJUnitResultFormatter.java
  Log:
  The xml formatter for JUnit will now honor test case names set with
  setName
  
  PR: 17040
  
  Revision  Changes    Path
  1.379     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.378
  retrieving revision 1.379
  diff -u -r1.378 -r1.379
  --- WHATSNEW  28 Mar 2003 08:28:15 -0000      1.378
  +++ WHATSNEW  28 Mar 2003 12:20:50 -0000      1.379
  @@ -195,6 +195,9 @@
   * Copy has a new outputencoding attribute that can be used to change
     the encoding while copying files.  Bugzilla Report 18217.
   
  +* The xml formatter for JUnit will now honor test case names set with
  +  setName.  Bugzilla Report 17040.
  +
   Changes from Ant 1.5.2 to Ant 1.5.3
   ===================================
   
  
  
  
  1.27      +18 -11    
ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
  
  Index: XMLJUnitResultFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- XMLJUnitResultFormatter.java      7 Mar 2003 11:23:06 -0000       1.26
  +++ XMLJUnitResultFormatter.java      28 Mar 2003 12:20:51 -0000      1.27
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -104,6 +104,10 @@
        */
       private Hashtable testElements = new Hashtable();
       /**
  +     * tests that failed.
  +     */
  +    private Hashtable failedTests = new Hashtable();
  +    /**
        * Timing helper.
        */
       private Hashtable testStarts = new Hashtable();
  @@ -186,12 +190,6 @@
        */
       public void startTest(Test t) {
           testStarts.put(t, new Long(System.currentTimeMillis()));
  -
  -        Element currentTest = doc.createElement(TESTCASE);
  -        currentTest.setAttribute(ATTR_NAME, 
  -                                 JUnitVersionHelper.getTestCaseName(t));
  -        rootElement.appendChild(currentTest);
  -        testElements.put(t, currentTest);
       }
   
       /**
  @@ -200,16 +198,24 @@
        * <p>A Test is finished.
        */
       public void endTest(Test test) {
  -        Element currentTest = (Element) testElements.get(test);
  -        
           // Fix for bug #5637 - if a junit.extensions.TestSetup is
           // used and throws an exception during setUp then startTest
           // would never have been called
  -        if (currentTest == null) {
  +        if (!testStarts.containsKey(test)) {
               startTest(test);
  +        }
  +
  +        Element currentTest = null;
  +        if (!failedTests.containsKey(test)) {
  +            currentTest = doc.createElement(TESTCASE);
  +            currentTest.setAttribute(ATTR_NAME, 
  +                                     
JUnitVersionHelper.getTestCaseName(test));
  +            rootElement.appendChild(currentTest);
  +            testElements.put(test, currentTest);
  +        } else {
               currentTest = (Element) testElements.get(test);
           }
  -        
  +
           Long l = (Long) testStarts.get(test);
           currentTest.setAttribute(ATTR_TIME,
               "" + ((System.currentTimeMillis() - l.longValue()) / 1000.0));
  @@ -245,6 +251,7 @@
       private void formatError(String type, Test test, Throwable t) {
           if (test != null) {
               endTest(test);
  +            failedTests.put(test, test);
           }
   
           Element nested = doc.createElement(type);
  
  
  

Reply via email to