git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@926465 13f79535-47bb-0310-9956-ffa450edef68master
@@ -48,6 +48,7 @@ Christoph Wilhelms | |||||
Christophe Labouisse | Christophe Labouisse | ||||
Christopher A. Longo | Christopher A. Longo | ||||
Christopher Charlier | Christopher Charlier | ||||
Clark Archer | |||||
Clemens Hammacher | Clemens Hammacher | ||||
Clement OUDOT | Clement OUDOT | ||||
Conor MacNeill | Conor MacNeill | ||||
@@ -96,6 +96,10 @@ Other changes: | |||||
meaningful error message | meaningful error message | ||||
Bugzilla Report 48834 | Bugzilla Report 48834 | ||||
* <junit> will now throw an exception if a test name is empty. This | |||||
used to manifest itself in unrelated errors like | |||||
Bugzilla Report 43586. | |||||
Changes from Ant 1.8.0RC1 TO Ant 1.8.0 | Changes from Ant 1.8.0RC1 TO Ant 1.8.0 | ||||
====================================== | ====================================== | ||||
@@ -214,6 +214,10 @@ | |||||
<first>Christopher</first> | <first>Christopher</first> | ||||
<last>Charlier</last> | <last>Charlier</last> | ||||
</name> | </name> | ||||
<name> | |||||
<first>Clark</first> | |||||
<last>Archer</last> | |||||
</name> | |||||
<name> | <name> | ||||
<first>Clemens</first> | <first>Clemens</first> | ||||
<last>Hammacher</last> | <last>Hammacher</last> | ||||
@@ -789,6 +789,8 @@ public class JUnitTask extends Task { | |||||
* @throws BuildException in case of test failures or errors | * @throws BuildException in case of test failures or errors | ||||
*/ | */ | ||||
protected void execute(JUnitTest arg) throws BuildException { | protected void execute(JUnitTest arg) throws BuildException { | ||||
validateTestName(arg.getName()); | |||||
JUnitTest test = (JUnitTest) arg.clone(); | JUnitTest test = (JUnitTest) arg.clone(); | ||||
// set the default values if not specified | // set the default values if not specified | ||||
//@todo should be moved to the test class instead. | //@todo should be moved to the test class instead. | ||||
@@ -812,6 +814,20 @@ public class JUnitTask extends Task { | |||||
actOnTestResult(result, test, "Test " + test.getName()); | actOnTestResult(result, test, "Test " + test.getName()); | ||||
} | } | ||||
/** | |||||
* Throws a <code>BuildException</code> if the given test name is invalid. | |||||
* Validity is defined as not <code>null</code>, not empty, and not the | |||||
* string "null". | |||||
* @param testName the test name to be validated | |||||
* @throws BuildException if <code>testName</code> is not a valid test name | |||||
*/ | |||||
private void validateTestName(String testName) throws BuildException { | |||||
if (testName == null || testName.length() == 0 | |||||
|| testName.equals("null")) { | |||||
throw new BuildException("test name must be specified"); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Execute a list of tests in a single forked Java VM. | * Execute a list of tests in a single forked Java VM. | ||||
* @param testList the list of tests to execute. | * @param testList the list of tests to execute. | ||||
@@ -289,4 +289,13 @@ public class BTest extends TestCase { | |||||
<au:assertLogDoesntContain text="Running test.HTest"/> | <au:assertLogDoesntContain text="Running test.HTest"/> | ||||
</target> | </target> | ||||
<target name="testMissingTestName"> | |||||
<property name="test.name" value="null"/> | |||||
<au:expectfailure message="test name must be specified"> | |||||
<junit fork="false"> | |||||
<test name="${test.name}"/> | |||||
</junit> | |||||
</au:expectfailure> | |||||
</target> | |||||
</project> | </project> |