Browse Source

Bugzilla 37426

Submitted by Maarten Coene
<junit> task doesn't print all the Test names when using forkmode='once'


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@370591 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 19 years ago
parent
commit
724483eec5
3 changed files with 21 additions and 11 deletions
  1. +3
    -0
      WHATSNEW
  2. +5
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  3. +13
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/SummaryJUnitResultFormatter.java

+ 3
- 0
WHATSNEW View File

@@ -178,6 +178,9 @@ Fixed bugs:
* Copy task would fail on locked (or otherwise uncopyable) files even if * Copy task would fail on locked (or otherwise uncopyable) files even if
failonerror set to false. Bugzilla report 38175. failonerror set to false. Bugzilla report 38175.


* <junit> task did not print all the Test names when using forkmode='once'.
Bugzilla report 37426.

Other changes: Other changes:
-------------- --------------
* Minor performance improvements Bugzilla report 37777 * Minor performance improvements Bugzilla report 37777


+ 5
- 9
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2005 The Apache Software Foundation
* Copyright 2000-2006 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -766,8 +766,8 @@ public class JUnitTask extends Task {
* @param watchdog the watchdog in charge of cancelling the test if it * @param watchdog the watchdog in charge of cancelling the test if it
* exceeds a certain amount of time. Can be <tt>null</tt>, in this case * exceeds a certain amount of time. Can be <tt>null</tt>, in this case
* the test could probably hang forever. * the test could probably hang forever.
* @param ForkedVMState will hold information about the forked
* VM's sanity.
* @param casesFile list of test cases to execute. Can be <tt>null</tt>,
* in this case only one test is executed.
* @throws BuildException in case of error creating a temporary property file, * @throws BuildException in case of error creating a temporary property file,
* or if the junit process can not be forked * or if the junit process can not be forked
*/ */
@@ -789,9 +789,6 @@ public class JUnitTask extends Task {
} }
cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"); cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner");
if (casesFile == null) { if (casesFile == null) {
if (summary) {
log("Running " + test.getName(), Project.MSG_INFO);
}
cmd.createArgument().setValue(test.getName()); cmd.createArgument().setValue(test.getName());
} else { } else {
log("Running multiple tests in the same VM", Project.MSG_VERBOSE); log("Running multiple tests in the same VM", Project.MSG_VERBOSE);
@@ -927,7 +924,7 @@ public class JUnitTask extends Task {
* The file will be in the project basedir unless tmpDir declares * The file will be in the project basedir unless tmpDir declares
* something else. * something else.
* @param prefix * @param prefix
* @return
* @return created file
*/ */
private File createTempPropertiesFile(String prefix) { private File createTempPropertiesFile(String prefix) {
File propsFile = File propsFile =
@@ -1073,7 +1070,6 @@ public class JUnitTask extends Task {
test.getHaltonfailure(), false, test.getHaltonfailure(), false,
true, classLoader); true, classLoader);
if (summary) { if (summary) {
log("Running " + test.getName(), Project.MSG_INFO);


SummaryJUnitResultFormatter f = SummaryJUnitResultFormatter f =
new SummaryJUnitResultFormatter(); new SummaryJUnitResultFormatter();
@@ -1438,7 +1434,7 @@ public class JUnitTask extends Task {
/** /**
* hashcode is based only on the boolean members, and returns a value * hashcode is based only on the boolean members, and returns a value
* in the range 0-7. * in the range 0-7.
* @return
* @return hash code value
*/ */
public int hashCode() { public int hashCode() {
return (filterTrace ? 1 : 0) return (filterTrace ? 1 : 0)


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

@@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2002,2004 The Apache Software Foundation
* Copyright 2000-2002,2004,2006 The Apache Software Foundation
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -50,9 +50,20 @@ public class SummaryJUnitResultFormatter implements JUnitResultFormatter {
public SummaryJUnitResultFormatter() { public SummaryJUnitResultFormatter() {
} }
/** /**
* Empty
* The testsuite started.
*/ */
public void startTestSuite(JUnitTest suite) { public void startTestSuite(JUnitTest suite) {
String newLine = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer("Running ");
sb.append(suite.getName());
sb.append(newLine);

try {
out.write(sb.toString().getBytes());
out.flush();
} catch (IOException ioex) {
throw new BuildException("Unable to write summary output", ioex);
}
} }
/** /**
* Empty * Empty


Loading…
Cancel
Save