Browse Source

don't assume a JUnit Test extends TestCase

PR: 4870


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269918 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
cf64423184
4 changed files with 8 additions and 4 deletions
  1. +3
    -0
      WHATSNEW
  2. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java

+ 3
- 0
WHATSNEW View File

@@ -34,6 +34,9 @@ Fixed bugs:


* <fixcrlf> would fail for files that contained lines longer than 8kB. * <fixcrlf> would fail for files that contained lines longer than 8kB.


* Some junit formatters incorrectly assumed that all testcases would
inherit from junit.framework.TestCase.

Other changes: Other changes:
-------------- --------------




+ 3
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelper.java View File

@@ -56,6 +56,7 @@ package org.apache.tools.ant.taskdefs.optional.junit;


import java.lang.reflect.Method; import java.lang.reflect.Method;


import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;


/** /**
@@ -85,8 +86,8 @@ public class JUnitVersionHelper {
* access to the name of a TestCase via reflection that is * access to the name of a TestCase via reflection that is
* supposed to work with version before and after JUnit 3.7. * supposed to work with version before and after JUnit 3.7.
*/ */
public static String getTestCaseName(TestCase t) {
if (testCaseName != null) {
public static String getTestCaseName(Test t) {
if (t instanceof TestCase && testCaseName != null) {
try { try {
return (String) testCaseName.invoke(t, new Object[0]); return (String) testCaseName.invoke(t, new Object[0]);
} catch (Throwable e) {} } catch (Throwable e) {}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java View File

@@ -200,7 +200,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter {
public void endTest(Test test) { public void endTest(Test test) {
synchronized (wri) { synchronized (wri) {
wri.print("Testcase: " wri.print("Testcase: "
+ JUnitVersionHelper.getTestCaseName((TestCase) test));
+ JUnitVersionHelper.getTestCaseName(test));
if (Boolean.TRUE.equals(failed.get(test))) { if (Boolean.TRUE.equals(failed.get(test))) {
return; return;
} }


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java View File

@@ -195,7 +195,7 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan


Element currentTest = doc.createElement(TESTCASE); Element currentTest = doc.createElement(TESTCASE);
currentTest.setAttribute(ATTR_NAME, currentTest.setAttribute(ATTR_NAME,
JUnitVersionHelper.getTestCaseName((TestCase) t));
JUnitVersionHelper.getTestCaseName(t));
rootElement.appendChild(currentTest); rootElement.appendChild(currentTest);
testElements.put(t, currentTest); testElements.put(t, currentTest);
} }


Loading…
Cancel
Save