Fixed an NPE if verbose is not specified explicitly.
diff --git a/src/main/java/org/testng/TestNG.java b/src/main/java/org/testng/TestNG.java
index 56bc4a2..47b1bcd 100644
--- a/src/main/java/org/testng/TestNG.java
+++ b/src/main/java/org/testng/TestNG.java
@@ -1,6 +1,13 @@
package org.testng;
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.ParameterException;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+import javax.xml.parsers.ParserConfigurationException;
+
import org.testng.annotations.ITestAnnotation;
import org.testng.collections.Lists;
import org.testng.collections.Maps;
@@ -34,11 +41,6 @@
import org.testng.xml.XmlTest;
import org.xml.sax.SAXException;
-import com.beust.jcommander.JCommander;
-import com.beust.jcommander.ParameterException;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -57,8 +59,6 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import javax.xml.parsers.ParserConfigurationException;
-
/**
* This class is the main entry point for running tests in the TestNG framework.
* Users can create their own TestNG object and invoke it in many different
@@ -881,7 +881,8 @@
if (m_suiteThreadPoolSize == 1 && !m_randomizeSuites) {
// Single threaded and not randomized: run the suites in order
for (XmlSuite xmlSuite : m_suites) {
- runSuitesSequentially(xmlSuite, suiteRunnerMap, xmlSuite.getVerbose(),
+ int verbose = getVerbose(xmlSuite);
+ runSuitesSequentially(xmlSuite, suiteRunnerMap, verbose,
getDefaultSuiteName());
}
} else {
@@ -926,6 +927,16 @@
}
/**
+ * @return the verbose level, checking in order: the verbose level on
+ * the suite, the verbose level on the TestNG object, or 1.
+ */
+ private int getVerbose(XmlSuite xmlSuite) {
+ int result = xmlSuite.getVerbose() != null ? xmlSuite.getVerbose()
+ : (m_verbose != null ? m_verbose : 1);
+ return result;
+ }
+
+ /**
* Recursively runs suites. Runs the children suites before running the parent
* suite. This is done so that the results for parent suite can reflect the
* combined results of the children suites.