Skip to content

Commit

Permalink
Fixed: The XML parser doesn't recognize parallel="instances"
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Beust committed Aug 26, 2011
1 parent 163505c commit aa48f78
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
@@ -1,5 +1,6 @@
Current

Fixed: The XML parser doesn't recognize parallel="instances"
Fixed: NPE when using inner classes
Fixed: @AfterClass not being run in some subclassing situations

Expand Down
30 changes: 12 additions & 18 deletions src/main/java/org/testng/xml/TestNGContentHandler.java
Expand Up @@ -136,16 +136,10 @@ private void xmlSuite(boolean start, Attributes attributes) {
m_currentSuite.setJUnit( Boolean.valueOf(jUnit).booleanValue());
}
String parallel = attributes.getValue("parallel");
if (null != parallel) {
if(XmlSuite.PARALLEL_METHODS.equals(parallel)
|| XmlSuite.PARALLEL_TESTS.equals(parallel)
|| XmlSuite.PARALLEL_NONE.equals(parallel)
|| XmlSuite.PARALLEL_CLASSES.equals(parallel)
|| "true".equals(parallel)
|| "false".equals(parallel)) {
if (parallel != null) {
if (isValidParallel(parallel)) {
m_currentSuite.setParallel(parallel);
}
else {
} else {
Utils.log("Parser", 1, "[WARN] Unknown value of attribute 'parallel' at suite level: '" + parallel + "'.");
}
}
Expand Down Expand Up @@ -273,16 +267,12 @@ private void xmlTest(boolean start, Attributes attributes) {
m_currentTest.setPreserveOrder(preserveOrder);
}
String parallel = attributes.getValue("parallel");
if (null != parallel) {
if(XmlSuite.PARALLEL_METHODS.equals(parallel)
|| XmlSuite.PARALLEL_NONE.equals(parallel)
|| XmlSuite.PARALLEL_CLASSES.equals(parallel)
|| "true".equals(parallel)
|| "false".equals(parallel)) {
if (parallel != null) {
if (isValidParallel(parallel)) {
m_currentTest.setParallel(parallel);
}
else {
Utils.log("Parser", 1, "[WARN] Unknown value of attribute 'parallel' for test '" + m_currentTest.getName() + "': '" + parallel + "'");
} else {
Utils.log("Parser", 1, "[WARN] Unknown value of attribute 'parallel' for test '"
+ m_currentTest.getName() + "': '" + parallel + "'");
}
}
String threadCount = attributes.getValue("thread-count");
Expand Down Expand Up @@ -322,6 +312,10 @@ private void xmlTest(boolean start, Attributes attributes) {
}
}

private boolean isValidParallel(String parallel) {
return XmlSuite.PARALLEL_MODES.contains(parallel);
}

/**
* Parse <classes>
*/
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/testng/xml/XmlSuite.java
Expand Up @@ -11,6 +11,7 @@
import org.testng.reporters.XMLStringBuffer;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -43,6 +44,15 @@ public class XmlSuite implements Serializable, Cloneable {
public static final String PARALLEL_CLASSES = "classes";
public static final String PARALLEL_INSTANCES = "instances";
public static final String PARALLEL_NONE = "none";
public static Set<String> PARALLEL_MODES = new HashSet<String>() {{
add(PARALLEL_TESTS);
add(PARALLEL_METHODS);
add(PARALLEL_CLASSES);
add(PARALLEL_INSTANCES);
add(PARALLEL_NONE);
add("true");
add("false");
}};

/** Configuration failure policy options */
public static final String SKIP = "skip";
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/testng-1.0.dtd
Expand Up @@ -59,7 +59,7 @@ Cedric Beust & Alexandru Popescu
name CDATA #REQUIRED
junit (true | false) "false"
verbose CDATA #IMPLIED
parallel (false | methods | tests | classes) "false"
parallel (false | methods | tests | classes | instances) "false"
configfailurepolicy (skip | continue) "skip"
thread-count CDATA "5"
annotations CDATA #IMPLIED
Expand Down

0 comments on commit aa48f78

Please sign in to comment.