[testng] 01/02: Import upstream version 6.8.13
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Sat Jan 3 18:07:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
eugene-guest pushed a commit to branch master
in repository testng.
commit de4301b84cd4bb79f0d1dab03f6338b4d3d4a555
Author: Eugene Zhukov <jevgeni.zh at gmail.com>
Date: Sat Jan 3 17:37:28 2015 +0000
Import upstream version 6.8.13
---
.classpath-linux | 11 +
.classpath-mac | 11 +
.gitignore | 26 +-
README | 2 +-
build.properties | 2 +-
build.xml | 9 +-
doc/documentation-main.html | 137 +++--
pom-test.xml | 2 +-
pom.xml | 2 +-
src/main/java/org/testng/ClassMethodMap.java | 4 +-
src/main/java/org/testng/TestRunner.java | 5 +-
src/main/java/org/testng/asserts/SoftAssert.java | 2 +-
src/main/java/org/testng/internal/Graph.java | 2 +-
.../java/org/testng/internal/MethodInstance.java | 6 +-
src/main/java/org/testng/internal/Parameters.java | 7 +-
.../java/org/testng/junit/JUnit4TestRunner.java | 37 +-
.../java/org/testng/reporters/XMLStringBuffer.java | 45 +-
src/main/java/org/testng/reporters/XMLUtils.java | 27 +-
.../org/testng/internal/MethodInstanceTest.java | 557 +++++++++++++++++++++
src/test/java/test/JUnit4Test.java | 2 +-
.../ExplicitDataProviderNameSample.java | 16 +
.../dataprovider/ExplicitDataProviderNameTest.java | 22 +
src/test/java/test/junit4/JUnit4Sample2.java | 8 +-
src/test/java/test/junit4/JUnit4SampleSuite.java | 2 +-
.../java/test/testng106/FailingSuiteFixture.java | 9 +-
src/test/java/test/testng106/TestNG106.java | 25 +
src/test/java/test/testng106/testng-106.xml | 25 -
src/test/java/test/testng387/FailedDPTest.java | 43 +-
src/test/java/test/testng387/TestNG387.java | 38 ++
src/test/resources/testng.xml | 8 +
30 files changed, 880 insertions(+), 212 deletions(-)
diff --git a/.classpath-linux b/.classpath-linux
new file mode 100644
index 0000000..d05023c
--- /dev/null
+++ b/.classpath-linux
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6"/>
+ <classpathentry kind="lib" path="lib/ant-1.6.5.jar"/>
+ <classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
+ <classpathentry kind="lib" path="lib/guice-2.0.jar"/>
+ <classpathentry kind="lib" path="lib/junit-3.8.1.jar"/>
+ <classpathentry kind="output" path="z_build"/>
+</classpath>
diff --git a/.classpath-mac b/.classpath-mac
new file mode 100644
index 0000000..d05023c
--- /dev/null
+++ b/.classpath-mac
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6"/>
+ <classpathentry kind="lib" path="lib/ant-1.6.5.jar"/>
+ <classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
+ <classpathentry kind="lib" path="lib/guice-2.0.jar"/>
+ <classpathentry kind="lib" path="lib/junit-3.8.1.jar"/>
+ <classpathentry kind="output" path="z_build"/>
+</classpath>
diff --git a/.gitignore b/.gitignore
index 42a9be4..c30969b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,17 @@
-debian/files
-debian/testng.debhelper.log
-debian/testng.substvars
-debian/testng/
-debian/maven-repo/
-debian/stamp-poms-patched
-.pc/
-test-output-tests/
-test-output/
+TESTNG-*
+ivy*
+eclipse-build
+javadocs
+target
+lib
+test-output
+test-output-tests
+z_build
+maven-testng-plugin-1.2.jar
+.settings
+src/test/java/test/ignore
+.classpath
+.project
+.idea
+testng.iml
+.ant-targets*
diff --git a/README b/README
index 8c21ad0..46784a2 100644
--- a/README
+++ b/README
@@ -4,7 +4,7 @@ Please note that even though the .zip distribution contains the TestNG sources,
you will not be able to build the software with them because we decided
not to include the external jar files in order to keep the size down.
-If you want to build TestNG, please sync to the GitHub repository at http://github.com/cbeust/testng.
+If you want to build TestNG, please sync to the GitHub repository at https://github.com/cbeust/testng.
--
The TestNG team
diff --git a/build.properties b/build.properties
index 1840023..085a02d 100644
--- a/build.properties
+++ b/build.properties
@@ -31,7 +31,7 @@ guice2.jar=guice-2.0.jar
junit.jar=junit-4.10.jar
ant.jar=ant-1.7.0.jar
jcommander.jar=jcommander-1.27.jar
-yaml.jar=snakeyaml-1.6.jar
+yaml.jar=snakeyaml-1.12.jar
all.jar.files=${beanshell.jar},${junit.jar},${ant.jar},${jcommander.jar},${yaml.jar},${guice2.jar}
diff --git a/build.xml b/build.xml
index a64982f..63477cc 100644
--- a/build.xml
+++ b/build.xml
@@ -113,11 +113,11 @@
<ant inheritall="no" antfile="examples/build.xml" />
</target>
- <target name="tests" depends="compile" description="runs all JDK5 tests with JDK5 distro">
+ <target name="tests" depends="build" description="runs all JDK5 tests with JDK5 distro">
<ant inheritall="no" antfile="build-tests.xml" />
</target>
- <target name="test-ant">
+ <target name="test-ant" depends="build">
<echo message=" -- Testing ant testng task functionality --" />
<ant inheritall="no" antfile="build-ant.xml" />
</target>
@@ -126,7 +126,7 @@
<!-- Documentation -->
<!-- ==================================================================== -->
- <target name="javadocs" depends="javadocs-current" />
+ <target name="javadocs" depends="build,javadocs-current" />
<target name="doclava">
<javadoc
@@ -248,7 +248,8 @@
</zip>
</target>
- <target name="create-jar" description="Create a jar file with the Testng classes and nothing else" >
+ <target name="create-jar" description="Create a jar file with the Testng classes and nothing else"
+ depends="compile">
<delete file="${jar.file}" />
<jar destfile="${jar.file}" >
<manifest>
diff --git a/doc/documentation-main.html b/doc/documentation-main.html
index 4473eb5..9a372bf 100644
--- a/doc/documentation-main.html
+++ b/doc/documentation-main.html
@@ -73,7 +73,9 @@ google_ad_channel ="5560744946";
<!-------------------------------------
INTRODUCTION
------------------------------------>
-<h3><a class="section" name="introduction">Introduction</a></h3>TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing (testing a class in isolation of the others) to integration testing (testing entire systems made of several classes, several packages and even several external frameworks, such as application servers).
+<h3><a class="section" name="introduction">Introduction</a></h3>
+
+TestNG is a testing framework designed to simplify a broad range of testing needs, from unit testing (testing a class in isolation of the others) to integration testing (testing entire systems made of several classes, several packages and even several external frameworks, such as application servers).
<p>
@@ -120,7 +122,9 @@ The rest of this manual will explain the following:
ANNOTATIONS
------------------------------------>
- <h3><a class="section" name="annotations">Annotations</a></h3>Here is a quick overview of the annotations available in TestNG along with their attributes.
+<h3><a class="section" name="annotations">Annotations</a></h3>
+
+Here is a quick overview of the annotations available in TestNG along with their attributes.
<p>
@@ -490,7 +494,9 @@ invocationCount. <br>Note: this attribute is ignored if invocationCount is not
<!-------------------------------------
TESTNG.XML
------------------------------------>
- <h3><a class="section" name="testng-xml">testng.xml</a></h3><p>You can invoke TestNG in several different ways:</p><ul>
+<h3><a class="section" name="testng-xml">testng.xml</a></h3>
+
+<p>You can invoke TestNG in several different ways:</p><ul>
<li>With a <tt>testng.xml</tt> file</li><li><a href="http://testng.org/doc/ant.html">With ant</a></li><li>From the command line</li></ul><p>This section describes the format of <tt>testng.xml</tt> (you will find documentation
on ant and the command line below).</p><p>The current DTD for <tt>testng.xml</tt> can be found on the main Web site:
<a href="http://testng.org/testng-1.0.dtd">http://testng.org/testng-1.0.dtd</a>
@@ -595,7 +601,9 @@ Please see the DTD for a complete list of the features, or read on.</p>
RUNNING TESTNG
------------------------------------>
-<h3><a class="section" name="running-testng">Running TestNG</a></h3>TestNG can be invoked in different ways:
+<h3><a class="section" name="running-testng">Running TestNG</a></h3>
+
+TestNG can be invoked in different ways:
<ul>
<li>Command line
@@ -820,7 +828,7 @@ The <a href="ant.html">ant task</a> and <a href="#testng-xml">testng.xml</a> all
<h3><a class="section" name="methods">Test methods, Test classes and Test groups</a></h3>
-<h4><a class="section" indent=".." name="test-groups">Test methods</a></h4>
+<h4><a class="section" indent=".." name="test-methods">Test methods</a></h4>
Test methods are annotated with <tt>@Test</tt>. Methods annotated with <tt>@Test</tt> that happen to return a value will be ignored, unless you set <tt>allow-return-values</tt> to <tt>true</tt> in your <tt>testng.xml</tt>:
@@ -1011,9 +1019,9 @@ would define this in your property file:
EXCLUSION
------------------------------------>
-<h4><a class="section" indent=".." name="exclusions">Exclusion groups</a>
+<h4><a class="section" indent=".." name="exclusions">Exclusion groups</a></h4>
-</h4><p>TestNG allows you to include groups as well as exclude them.</p>
+<p>TestNG allows you to include groups as well as exclude them.</p>
For example, it is quite usual to have tests that temporarily break because
@@ -1056,14 +1064,14 @@ broken and need to be fixed later.</p>
<p><i>Note: you can also disable tests on an individual basis by using the
"enabled" property available on both @Test and @Before/After
annotations.</i></p>
-</blockquote><h4>
+</blockquote>
<!-------------------------------------
PARTIAL GROUPS
------------------------------------>
-<a class="section" indent=".." name="partial-groups">Partial groups</a></h4>
+<h4><a class="section" indent=".." name="partial-groups">Partial groups</a></h4>
You can define groups at the class level and then add groups at the method level:
@@ -1087,7 +1095,9 @@ at the class level, while method1() belongs to both "checkin-test" and
PARAMETERS
------------------------------------>
-<h4><a class="section" indent=".." name="parameters">Parameters</a></h4><p>
+<h4><a class="section" indent=".." name="parameters">Parameters</a></h4>
+
+<p>
Test methods don't have to be parameterless. You can use an arbitrary
@@ -1096,10 +1106,10 @@ pass you the correct parameters with the <tt>@Parameters</tt> annotation.</p><p>
There are two ways to set these parameters: with <tt>testng.xml</tt> or
-programmatically.</p><p>
+programmatically.</p>
-<em><a class="section" indent="..." name="parameters-testng-xml">Parameters from <tt>testng.xml</tt></a></em></p>
+<h5><a class="section" indent="..." name="parameters-testng-xml">Parameters from <tt>testng.xml</tt></a></h5>
If you are using simple values for your parameters, you can specify them in your
@@ -1181,7 +1191,7 @@ tests. </i>
</blockquote>
-<em><a class="section" indent="..." name="parameters-dataproviders">Parameters with DataProviders</a></em>
+<h5><a class="section" indent="..." name="parameters-dataproviders">Parameters with DataProviders</a></h5>
<p>Specifying parameters in <tt>testng.xml</tt> might not be sufficient if you need to pass complex parameters, or parameters that need to be created from Java (complex objects, objects read from a property file or a database, etc...). In this case, you can use a Data Provider to supply the values you need to test. A Data Provider is a method on your class that returns an array of array of objects. This method is annotated with <tt>@DataProvider</tt>:
@@ -1302,7 +1312,7 @@ If you want to run a few specific data providers in a different thread pool, you
<p>
-<em><a class="section" indent="..." name="parameters-reports">Parameters in reports</a></em>
+<h5><a class="section" indent="..." name="parameters-reports">Parameters in reports</a></h5>
<p>
@@ -1321,7 +1331,9 @@ Parameters used to invoke your test methods are shown in the HTML reports genera
------------------------------------>
-<h4><a class="section" indent=".." name="dependent-methods">Dependencies</a></h4><p>Sometimes, you need
+<h4><a class="section" indent=".." name="dependent-methods">Dependencies</a></h4>
+
+<p>Sometimes, you need
your test methods to be invoked in a certain order. Here are a
few examples:
@@ -1441,9 +1453,7 @@ The <tt><depends-on></tt> attribute contains a space-separated list of gro
FACTORIES
------------------------------------>
-<h4>
-<a class="section" indent=".." name="factories">Factories</a>
-</h4>
+<h4><a class="section" indent=".." name="factories">Factories</a></h4>
Factories allow you to create tests dynamically. For example, imagine you
want to create a test method that will access a page on a Web site several
@@ -1599,7 +1609,7 @@ will make both <tt>test1()</tt> and <tt>test2()</tt> test methods but on top of
You can instruct TestNG to run your tests in separate threads in various ways.
-<h5><a class="section" indent="..." name="parallel-tests">Parallel suites</a></h5>
+<h5><a class="section" indent="..." name="parallel-suites">Parallel suites</a></h5>
This is useful if you are running several suite files (e.g. "<tt>java org.testng.TestNG testng1.xml testng2.xml"</tt>) and you want each of these suites to be run in a separate thread. You can use the following command line flag to specify the size of a thread pool:
@@ -1673,7 +1683,9 @@ In this example, the function <tt>testServer</tt> will be invoked ten times from
------------------------------------>
-<h4><a class="section" indent=".." name="rerunning">Rerunning failed tests</a></h4>Every time tests fail in a suite, TestNG creates a file called <tt>testng-failed.xml</tt> in the output directory.
+<h4><a class="section" indent=".." name="rerunning">Rerunning failed tests</a></h4>
+
+Every time tests fail in a suite, TestNG creates a file called <tt>testng-failed.xml</tt> in the output directory.
This XML file contains the necessary information to rerun only these methods
that failed, allowing you to quickly reproduce the failures without having to
run the entirety of your tests. Therefore, a typical session would look
@@ -1718,16 +1730,16 @@ property and set the <tt>testng.junit</tt> property to true:
</ul>
</li>
</ul>
- <!-------------------------------------
+
+<!-------------------------------------
JUNIT
- ------------------------------------><h4>
+--------------------------------------->
<!-------------------------------------
RUNNING TESTNG
- ------------------------------------><h4>
-<a class="section" indent=".." name="running-testng-programmatically">Running TestNG programmatically</a>
-</h4>
+ ------------------------------------>
+<h4><a class="section" indent=".." name="running-testng-programmatically">Running TestNG programmatically</a></h4>
You can invoke TestNG from your own programs very easily:
@@ -1785,9 +1797,7 @@ tng.run();
BEANSHELL
------------------------------------>
-<h4>
-<a class="section" indent=".." name="beanshell">BeanShell and advanced group selection</a>
-</h4>
+<h4><a class="section" indent=".." name="beanshell">BeanShell and advanced group selection</a></h4>
<p>If the <tt><include></tt> and <tt><exclude></tt> tags in <tt>testng.xml</tt> are not enough for your needs, you can use a <a href="http://beanshell.org">BeanShell</a> expression to decide whether a certain test method should be included in a test run or not. You specify this expression just under the <tt><test></tt> tag:</p>
@@ -1821,9 +1831,7 @@ You might want to surround your expression with a <tt>CDATA</tt> declaration (as
ANNOTATION TRANSFORMERS
------------------------------------>
-<h4>
-<a class="section" indent=".." name="annotationtransformers">Annotation Transformers</a>
-</h4>
+<h4><a class="section" indent=".." name="annotationtransformers">Annotation Transformers</a></h4>
TestNG allows you to modify the content of all the annotations at runtime. This is especially useful if the annotations in the source code are right most of the time, but there are a few situations where you'd like to override their value.
<p>
@@ -1900,9 +1908,8 @@ For example, here is how you would override the attribute <tt>invocationCount</t
METHOD INTERCEPTORS
------------------------------------>
-<h4>
-<a class="section" indent=".." name="methodinterceptors">Method Interceptors</a>
-</h4>
+<h4><a class="section" indent=".." name="methodinterceptors">Method Interceptors</a></h4>
+
Once TestNG has calculated in what order the test methods will be invoked, these methods are split in two groups:
<ul>
@@ -1968,9 +1975,7 @@ public List<IMethodInstance> intercept(List<IMethodInstance> methods
TESTNG LISTENERS
------------------------------------>
-<h4>
-<a class="section" indent=".." name="testng-listeners">TestNG Listeners</a>
-</h4>
+<h4><a class="section" indent=".." name="testng-listeners">TestNG Listeners</a></h4>
There are several interfaces that allow you to modify TestNG's behavior. These interfaces are broadly called "TestNG Listeners". Here are a few listeners:
@@ -1995,7 +2000,7 @@ When you implement one of these interfaces, you can let TestNG know about it wit
<li>Using <tt>ServiceLoader</tt>.
</ul>
-<h3><a class="section" indent="..." name="listeners-testng-xml">Specifying listeners with <tt>testng.xml</tt> or in Java</a></h3>
+<h5><a class="section" indent="..." name="listeners-testng-xml">Specifying listeners with <tt>testng.xml</tt> or in Java</a></h5>
Here is how you can define listeners in your <tt>testng.xml</tt> file:
@@ -2026,7 +2031,7 @@ The <tt>@Listeners</tt> annotation can contain any class that extends <tt>org.te
Note that the <tt>@Listeners</tt> annotation will apply to your entire suite file, just as if you had specified it in a <tt>testng.xml</tt> file. If you want to restrict its scope (for example, only running on the current class), the code in your listener could first check the test method that's about to run and decide what to do then.
-<h3><a class="section" indent="..." name="listeners-service-loader">Specifying listeners with <tt>ServiceLoader</tt></a></h3>
+<h5><a class="section" indent="..." name="listeners-service-loader">Specifying listeners with <tt>ServiceLoader</tt></a></h5>
Finally, the JDK offers a very elegant mechanism to specify implementations of interfaces on the class path via the <tt><a href="http://download.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html">ServiceLoader</a></tt> class.
@@ -2104,15 +2109,11 @@ This mechanism allows you to apply the same set of listeners to an entire organi
DEPENDENCY INJECTION
------------------------------------>
-<h4>
-<a class="section" indent=".." name="dependency-injection">Dependency injection</a>
-</h4>
+<h4><a class="section" indent=".." name="dependency-injection">Dependency injection</a></h4>
TestNG supports two different kinds of dependency injection: native (performed by TestNG itself) and external (performed by a dependency injection framework such as Guice).
-<h5>
-<a class="section" indent="..." name="native-dependency-injection">Native dependency injection</a>
-</h5>
+<h5><a class="section" indent="..." name="native-dependency-injection">Native dependency injection</a></h5>
TestNG lets you declare additional parameters in your methods. When this happens, TestNG will automatically fill these parameters with the right value. Dependency injection can be used in the following places:
@@ -2159,9 +2160,7 @@ public class NoInjectionTest {
}
</pre>
-<h5>
-<a class="section" indent="..." name="guice-dependency-injection">Guice dependency injection</a>
-</h5>
+<h5><a class="section" indent="..." name="guice-dependency-injection">Guice dependency injection</a></h5>
If you use Guice, TestNG gives you an easy way to inject your test objects with a Guice module:
@@ -2298,9 +2297,7 @@ This configuration ensures you that all tests in this suite will be run with sam
INVOKED METHOD LISTENERS
------------------------------------>
-<h4>
-<a class="section" indent=".." name="invokedmethodlistener">Listening to method invocations</a>
-</h4>
+<h4><a class="section" indent=".." name="invokedmethodlistener">Listening to method invocations</a></h4>
The listener <tt><a href="../javadocs/org/testng/IInvokedMethodListener.html">IInvokedMethodListener</a></tt> allows you to be notified whenever TestNG is about to invoke a test (annotated with <tt>@Test</tt>) or configuration (annotated with any of the <tt>@Before</tt> or <tt>@After</tt> annotation) method. You need to implement the following interface:
@@ -2320,9 +2317,7 @@ and declare it as a listener, as explained in <a href="#testng-listeners">the se
IHOOKABLE AND ICONFIGURABLE
------------------------------------>
-<h4>
-<a class="section" indent=".." name="ihookable">Overriding test methods</a></h4>
-</h4>
+<h4><a class="section" indent=".." name="ihookable">Overriding test methods</a></h4>
TestNG allows you to override and possibly skip the invocation of test methods. One example of where this is useful is if you need to your test methods with a specific security manager. You achieve this by providing a listener that implements <a href="../javadocs/org/testng/IHookable.html"><tt>IHookable</tt></a>.
<p>
@@ -2347,14 +2342,10 @@ public class MyHook implements IHookable {
TEST SUCCESS
------------------------------------>
-<h3>
-<a class="section" indent="." name="test-results">Test results</a>
-</h3>
+<h3><a class="section" indent="." name="test-results">Test results</a></h3>
-<h4>
-<a class="section" indent=".." name="success-failure">Success, failure and assert</a>
-</h4>
+<h4><a class="section" indent=".." name="success-failure">Success, failure and assert</a></h4>
<p>A test is considered successful if it completed without throwing any
@@ -2394,9 +2385,9 @@ public void verify() {
------------------------------------>
</p>
-<h3><a class="section" indent=".." name="logging">Logging and results</a>
+<h4><a class="section" indent=".." name="logging">Logging and results</a></h4>
-</h3>The results of the test run are created in a file called <tt>index.html</tt> in the
+The results of the test run are created in a file called <tt>index.html</tt> in the
directory specified when launching SuiteRunner. This file points to
various other HTML and text files that contain the result of the entire test
run. You can see a typical example
@@ -2408,10 +2399,7 @@ It's very easy to generate your own reports with TestNG with Listeners and Repor
<ul>
<li><b>Listeners</b> implement the interface <a href="../javadocs/org/testng/ITestListener.html"><tt>org.testng.ITestListener</tt></a> and are notified in real time of when a test starts, passes, fails, etc...</li><li><b>Reporters</b> implement the interface <a href="../javadocs/org/testng/IReporter.html"><tt>org.testng.IReporter</tt></a> and are notified when all the suites have been run by TestNG. The IReporter instance receives a list of objects that describe the entire test run.</li [...]
-<p>
-
-<a class="section" indent="..." name="logging-listeners">Logging Listeners</a>
-<p>
+<h5><a class="section" indent="..." name="logging-listeners">Logging Listeners</a></h5>
Here is a listener that displays a "." for each passed test, a "F" for each failure and a "S" for each skip:
@@ -2473,11 +2461,7 @@ Total tests run: 226, Failures: 0, Skips: 0
Note that when you use <tt>-listener</tt>, TestNG will automatically determine the type of listener you want to use.
-<p>
-
-<a class="section" indent="..." name="logging-reporters">Logging Reporters</a>
-
-<p>
+<h5><a class="section" indent="..." name="logging-reporters">Logging Reporters</a></h5>
The <a href="../javadocs/org/testng/IReporter.html"><tt>org.testng.IReporter</tt></a> interface only has one method:
@@ -2489,7 +2473,7 @@ This method will be invoked by TestNG when all the suites have been run and you
<p>
-<a class="section" indent="..." name="logging-junitreports">JUnitReports</a>
+<h5><a class="section" indent="..." name="logging-junitreports">JUnitReports</a></h5>
<p>
@@ -2516,7 +2500,7 @@ prevents the frame version from working, so you need to specify "noframes&q
get this to work for now.</em>
</blockquote>
-<a class="section" indent="..." name="logging-reporter-api">Reporter API</a>
+<h5><a class="section" indent="..." name="logging-reporter-api">Reporter API</a></h5>
<p>
If you need to log messages that should appear in the generated HTML reports, you can use the class <tt><a href="../javadocs/org/testng/Reporter.html">org.testng.Reporter</a></tt>:
@@ -2533,7 +2517,8 @@ If you need to log messages that should appear in the generated HTML reports, yo
</p>
-<a class="section" indent="..." name="logging-xml-reports">XML Reports</a>
+<h5><a class="section" indent="..." name="logging-xml-reports">XML Reports</a></h5>
+
<p>
TestNG offers an XML reporter capturing TestNG specific information that is not available in JUnit reports. This is particulary useful when the user's test environment needs to consume XML results with TestNG-specific data that the JUnit format can't provide. Below is a sample of the output of such a reporter:
</p>
@@ -2666,9 +2651,7 @@ TestNG offers an XML reporter capturing TestNG specific information that is not
YAML
------------------------------------>
-<h3>
-<a class="section" name="yaml">YAML</a>
-</h3>
+<h3><a class="section" name="yaml">YAML</a></h3>
TestNG supports <a href="http://www.yaml.org/">YAML</a> as an alternate way of specifying your suite file. For example, the following XML file:
diff --git a/pom-test.xml b/pom-test.xml
index 8a29968..d318865 100644
--- a/pom-test.xml
+++ b/pom-test.xml
@@ -72,7 +72,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.8.8-SNAPSHOT</version>
+ <version>6.8.9-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/pom.xml b/pom.xml
index 7a380c3..ac16a84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
<artifactId>testng</artifactId>
<packaging>jar</packaging>
<name>TestNG</name>
- <version>6.8.8</version>
+ <version>6.8.13</version>
<description>TestNG is a testing framework.</description>
<url>http://testng.org</url>
diff --git a/src/main/java/org/testng/ClassMethodMap.java b/src/main/java/org/testng/ClassMethodMap.java
index 658bc50..f75b1a8 100755
--- a/src/main/java/org/testng/ClassMethodMap.java
+++ b/src/main/java/org/testng/ClassMethodMap.java
@@ -28,7 +28,9 @@ public class ClassMethodMap {
// Only add to the class map methods that are included in the
// method selector. We can pass a null context here since the selector
// should already have been initialized
- if (! xmlMethodSelector.includeMethod(null, m, true)) continue;
+ if (xmlMethodSelector != null){
+ if (! xmlMethodSelector.includeMethod(null, m, true)) continue;
+ }
Object instance = m.getInstance();
List<ITestNGMethod> l = m_classMap.get(instance);
diff --git a/src/main/java/org/testng/TestRunner.java b/src/main/java/org/testng/TestRunner.java
index a636c21..1f2936b 100644
--- a/src/main/java/org/testng/TestRunner.java
+++ b/src/main/java/org/testng/TestRunner.java
@@ -790,7 +790,10 @@ public class TestRunner
for (IMethodInstance imi : resultInstances) {
result.add(imi.getMethod());
}
-
+ //Since an interceptor is involved, we would need to ensure that the ClassMethodMap object is in sync with the
+ //output of the interceptor, else @AfterClass doesn't get executed at all when interceptors are involved.
+ //so let's update the current classMethodMap object with the list of methods obtained from the interceptor.
+ this.m_classMethodMap = new ClassMethodMap(result, null);
return result.toArray(new ITestNGMethod[result.size()]);
}
diff --git a/src/main/java/org/testng/asserts/SoftAssert.java b/src/main/java/org/testng/asserts/SoftAssert.java
index c230314..f06f1d5 100644
--- a/src/main/java/org/testng/asserts/SoftAssert.java
+++ b/src/main/java/org/testng/asserts/SoftAssert.java
@@ -33,7 +33,7 @@ public class SoftAssert extends Assertion {
} else {
sb.append(", ");
}
- sb.append(ae.getValue().getMessage());
+ sb.append(ae.getKey().getMessage());
}
throw new AssertionError(sb.toString());
}
diff --git a/src/main/java/org/testng/internal/Graph.java b/src/main/java/org/testng/internal/Graph.java
index 9a0ce75..f7ba442 100644
--- a/src/main/java/org/testng/internal/Graph.java
+++ b/src/main/java/org/testng/internal/Graph.java
@@ -19,7 +19,7 @@ import java.util.Set;
*/
public class Graph<T> {
private static boolean m_verbose = false;
- private Map<T, Node<T>> m_nodes = Maps.newHashMap();
+ private Map<T, Node<T>> m_nodes = Maps.newLinkedHashMap();
private List<T> m_strictlySortedNodes = null;
// A map of nodes that are not the predecessors of any node
diff --git a/src/main/java/org/testng/internal/MethodInstance.java b/src/main/java/org/testng/internal/MethodInstance.java
index cb0a976..5b47885 100755
--- a/src/main/java/org/testng/internal/MethodInstance.java
+++ b/src/main/java/org/testng/internal/MethodInstance.java
@@ -63,7 +63,11 @@ public class MethodInstance implements IMethodInstance {
// This can happen if these classes came from a @Factory, in which case, they
// don't have an associated XmlClass
- if (class1 == null || class2 == null) return 0;
+ if (class1 == null || class2 == null) {
+ if (class1 != null) return -1;
+ if (class2 != null) return 1;
+ return 0;
+ }
if (! class1.getName().equals(class2.getName())) {
int index1 = class1.getIndex();
diff --git a/src/main/java/org/testng/internal/Parameters.java b/src/main/java/org/testng/internal/Parameters.java
index b6072a7..3708011 100755
--- a/src/main/java/org/testng/internal/Parameters.java
+++ b/src/main/java/org/testng/internal/Parameters.java
@@ -15,6 +15,7 @@ import org.testng.internal.ParameterHolder.ParameterOrigin;
import org.testng.internal.annotations.AnnotationHelper;
import org.testng.internal.annotations.IAnnotationFinder;
import org.testng.internal.annotations.IDataProvidable;
+import org.testng.util.Strings;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;
@@ -326,7 +327,7 @@ public class Parameters {
for (Method m : ClassHelper.getAvailableMethods(cls)) {
IDataProviderAnnotation dp = (IDataProviderAnnotation)
finder.findAnnotation(m, IDataProviderAnnotation.class);
- if (null != dp && (name.equals(dp.getName()) || name.equals(m.getName()))) {
+ if (null != dp && name.equals(getDataProviderName(dp, m))) {
if (shouldBeStatic && (m.getModifiers() & Modifier.STATIC) == 0) {
throw new TestNGException("DataProvider should be static: " + m);
}
@@ -341,6 +342,10 @@ public class Parameters {
return result;
}
+ private static String getDataProviderName(IDataProviderAnnotation dp, Method m) {
+ return Strings.isNullOrEmpty(dp.getName()) ? m.getName() : dp.getName();
+ }
+
@SuppressWarnings({"deprecation"})
private static Object[] createParameters(Method m, MethodParameters params,
IAnnotationFinder finder, XmlSuite xmlSuite, Class annotationClass, String atName)
diff --git a/src/main/java/org/testng/junit/JUnit4TestRunner.java b/src/main/java/org/testng/junit/JUnit4TestRunner.java
index 9d7fa6d..2b81fcc 100644
--- a/src/main/java/org/testng/junit/JUnit4TestRunner.java
+++ b/src/main/java/org/testng/junit/JUnit4TestRunner.java
@@ -111,25 +111,28 @@ public class JUnit4TestRunner implements IJUnitTestRunner {
private class RL extends RunListener {
private Map<Description, ITestResult> runs = new WeakHashMap<Description, ITestResult>();
- private List<Description> failures = new LinkedList<Description>();
+ private List<Description> notified = new LinkedList<Description>();
@Override
public void testAssumptionFailure(Failure failure) {
- super.testAssumptionFailure(failure);
+ notified.add(failure.getDescription());
ITestResult tr = runs.get(failure.getDescription());
- tr.setStatus(TestResult.FAILURE);
+ tr.setStatus(TestResult.SKIP);
tr.setEndMillis(Calendar.getInstance().getTimeInMillis());
tr.setThrowable(failure.getException());
- m_parentRunner.addFailedTest(tr.getMethod(), tr);
+ m_parentRunner.addSkippedTest(tr.getMethod(), tr);
for (ITestListener l : m_listeners) {
- l.onTestFailure(tr);
+ l.onTestSkipped(tr);
}
}
@Override
public void testFailure(Failure failure) throws Exception {
- super.testFailure(failure);
- failures.add(failure.getDescription());
+ if (isAssumptionFailed(failure)) {
+ this.testAssumptionFailure(failure);
+ return;
+ }
+ notified.add(failure.getDescription());
ITestResult tr = runs.get(failure.getDescription());
tr.setStatus(TestResult.FAILURE);
tr.setEndMillis(Calendar.getInstance().getTimeInMillis());
@@ -142,9 +145,8 @@ public class JUnit4TestRunner implements IJUnitTestRunner {
@Override
public void testFinished(Description description) throws Exception {
- super.testFinished(description);
ITestResult tr = runs.get(description);
- if (!failures.contains(description)) {
+ if (!notified.contains(description)) {
tr.setStatus(TestResult.SUCCESS);
tr.setEndMillis(Calendar.getInstance().getTimeInMillis());
m_parentRunner.addPassedTest(tr.getMethod(), tr);
@@ -157,7 +159,6 @@ public class JUnit4TestRunner implements IJUnitTestRunner {
@Override
public void testIgnored(Description description) throws Exception {
- super.testIgnored(description);
ITestResult tr = createTestResult(description);
tr.setStatus(TestResult.SKIP);
tr.setEndMillis(tr.getStartMillis());
@@ -170,17 +171,14 @@ public class JUnit4TestRunner implements IJUnitTestRunner {
@Override
public void testRunFinished(Result result) throws Exception {
- super.testRunFinished(result);
}
@Override
public void testRunStarted(Description description) throws Exception {
- super.testRunStarted(description);
}
@Override
public void testStarted(Description description) throws Exception {
- super.testStarted(description);
ITestResult tr = createTestResult(description);
runs.put(description, tr);
for (ITestListener l : m_listeners) {
@@ -208,4 +206,17 @@ public class JUnit4TestRunner implements IJUnitTestRunner {
return tr;
}
}
+
+ private static boolean isAssumptionFailed(Failure failure) {
+ if (failure == null) {
+ return false;
+ }
+ //noinspection ThrowableResultOfMethodCallIgnored
+ final Throwable exception = failure.getException();
+ //noinspection SimplifiableIfStatement
+ if (exception == null) {
+ return false;
+ }
+ return "org.junit.internal.AssumptionViolatedException".equals(exception.getClass().getCanonicalName());
+ }
}
diff --git a/src/main/java/org/testng/reporters/XMLStringBuffer.java b/src/main/java/org/testng/reporters/XMLStringBuffer.java
index 441ac6b..092c10e 100755
--- a/src/main/java/org/testng/reporters/XMLStringBuffer.java
+++ b/src/main/java/org/testng/reporters/XMLStringBuffer.java
@@ -1,5 +1,7 @@
package org.testng.reporters;
+import org.testng.internal.Nullable;
+
import java.io.Writer;
import java.util.Properties;
import java.util.Stack;
@@ -64,7 +66,7 @@ public class XMLStringBuffer {
* @param start A string of spaces indicating the indentation at which
* to start the generation.
*/
- private void init(IBuffer buffer, String start, String version, String encoding) {
+ private void init(IBuffer buffer, String start, @Nullable String version, @Nullable String encoding) {
m_buffer = buffer;
m_currentIndent = start;
if (version != null) {
@@ -80,7 +82,7 @@ public class XMLStringBuffer {
*/
public void setXmlDetails(String v, String enc) {
if (m_buffer.toString().length() != 0) {
- throw new RuntimeException("Buffer should be empty: '" + m_buffer.toString() + "'");
+ throw new IllegalStateException("Buffer should be empty: '" + m_buffer.toString() + "'");
}
m_buffer.append("<?xml version=\"" + v + "\" encoding=\"" + enc + "\"?>").append(EOL);
}
@@ -102,7 +104,7 @@ public class XMLStringBuffer {
* @param schema The schema to use (can be null or an empty string).
* @param attributes A Properties file representing the attributes (or null)
*/
- public void push(String tagName, String schema, Properties attributes) {
+ public void push(String tagName, @Nullable String schema, @Nullable Properties attributes) {
XMLUtils.xmlOpen(m_buffer, m_currentIndent, tagName + schema, attributes);
m_tagStack.push(new Tag(m_currentIndent, tagName, attributes));
m_currentIndent += DEFAULT_INDENT_INCREMENT;
@@ -115,7 +117,7 @@ public class XMLStringBuffer {
* @param tagName The name of the tag.
* @param schema The schema to use (can be null or an empty string).
*/
- public void push(String tagName, String schema) {
+ public void push(String tagName, @Nullable String schema) {
push(tagName, schema, null);
}
@@ -126,7 +128,7 @@ public class XMLStringBuffer {
* @param tagName The name of the tag.
* @param attributes A Properties file representing the attributes (or null)
*/
- public void push(String tagName, Properties attributes) {
+ public void push(String tagName, @Nullable Properties attributes) {
push(tagName, "", attributes);
}
@@ -136,6 +138,12 @@ public class XMLStringBuffer {
private Properties createProperties(String[] attributes) {
Properties result = new Properties();
+ if (attributes == null) {
+ return result;
+ }
+ if (attributes.length % 2 != 0) {
+ throw new IllegalArgumentException("Arguments 'attributes' length must be even. Actual: " + attributes.length);
+ }
for (int i = 0; i < attributes.length; i += 2) {
result.put(attributes[i], attributes[i + 1]);
}
@@ -186,7 +194,7 @@ public class XMLStringBuffer {
* @param tagName The name of the tag
* @param value The value for this tag
*/
- public void addRequired(String tagName, String value) {
+ public void addRequired(String tagName, @Nullable String value) {
addRequired(tagName, value, (Properties) null);
}
@@ -197,10 +205,10 @@ public class XMLStringBuffer {
* @param value The value for this tag
* @param attributes A Properties file containing the attributes (or null)
*/
- public void addRequired(String tagName, String value, Properties attributes) {
+ public void addRequired(String tagName, @Nullable String value, @Nullable Properties attributes) {
XMLUtils.xmlRequired(m_buffer, m_currentIndent, tagName, value, attributes);
}
- public void addRequired(String tagName, String value, String... attributes) {
+ public void addRequired(String tagName, @Nullable String value, String... attributes) {
addRequired(tagName, value, createProperties(attributes));
}
@@ -211,12 +219,16 @@ public class XMLStringBuffer {
* @param value The value for this tag
* @param attributes A Properties file containing the attributes (or null)
*/
- public void addOptional(String tagName, String value, Properties attributes) {
- XMLUtils.xmlOptional(m_buffer, m_currentIndent, tagName, value, attributes);
+ public void addOptional(String tagName, @Nullable String value, @Nullable Properties attributes) {
+ if (value != null) {
+ XMLUtils.xmlOptional(m_buffer, m_currentIndent, tagName, value, attributes);
+ }
}
- public void addOptional(String tagName, String value, String... attributes) {
- XMLUtils.xmlOptional(m_buffer, m_currentIndent, tagName, value, createProperties(attributes));
+ public void addOptional(String tagName, @Nullable String value, String... attributes) {
+ if (value != null) {
+ XMLUtils.xmlOptional(m_buffer, m_currentIndent, tagName, value, createProperties(attributes));
+ }
}
/**
@@ -225,7 +237,7 @@ public class XMLStringBuffer {
* @param tagName The name of the tag
* @param value The value for this tag
*/
- public void addOptional(String tagName, String value) {
+ public void addOptional(String tagName, @Nullable String value) {
addOptional(tagName, value, (Properties) null);
}
@@ -236,7 +248,7 @@ public class XMLStringBuffer {
* @param value The value for this tag
* @param attributes A Properties file containing the attributes (or null)
*/
- public void addOptional(String tagName, Boolean value, Properties attributes) {
+ public void addOptional(String tagName, @Nullable Boolean value, @Nullable Properties attributes) {
if (null != value) {
XMLUtils.xmlOptional(m_buffer, m_currentIndent, tagName, value.toString(), attributes);
}
@@ -247,9 +259,8 @@ public class XMLStringBuffer {
* added.
* @param tagName The name of the tag
* @param value The value for this tag
- * @param attributes A Properties file containing the attributes (or null)
*/
- public void addOptional(String tagName, Boolean value) {
+ public void addOptional(String tagName, @Nullable Boolean value) {
addOptional(tagName, value, null);
}
@@ -268,7 +279,7 @@ public class XMLStringBuffer {
* @param tagName The name of the tag
* @param attributes A Properties file containing the attributes (or null)
*/
- public void addEmptyElement(String tagName, Properties attributes) {
+ public void addEmptyElement(String tagName, @Nullable Properties attributes) {
m_buffer.append(m_currentIndent).append("<").append(tagName);
XMLUtils.appendAttributes(m_buffer, attributes);
m_buffer.append("/>").append(EOL);
diff --git a/src/main/java/org/testng/reporters/XMLUtils.java b/src/main/java/org/testng/reporters/XMLUtils.java
index 5fd03ef..afe61af 100755
--- a/src/main/java/org/testng/reporters/XMLUtils.java
+++ b/src/main/java/org/testng/reporters/XMLUtils.java
@@ -1,5 +1,7 @@
package org.testng.reporters;
+import org.testng.internal.Nullable;
+
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Map.Entry;
@@ -20,12 +22,23 @@ public final class XMLUtils {
// Hide constructor
}
- static public String xml(String indent, String elementName, String content,
- Properties attributes) {
+ /**
+ * Generate tag.
+ * An opening and closing tag will be generated even if value is null.
+ * @param name name of the tag
+ * @param content content for this tag (or null)
+ * @param attributes tag attributes (or null)
+ */
+ static public String xml(String indent,
+ String name,
+ @Nullable String content,
+ @Nullable Properties attributes) {
IBuffer result = Buffer.create();
- xmlOpen(result, indent, elementName, attributes, true /* no newline */);
- result.append(content);
- xmlClose(result, "", elementName, XMLUtils.extractComment(elementName, attributes));
+ xmlOpen(result, indent, name, attributes, true /* no newline */);
+ if (content != null) {
+ result.append(content);
+ }
+ xmlClose(result, "", name, XMLUtils.extractComment(name, attributes));
return result.toString();
}
@@ -52,14 +65,14 @@ public final class XMLUtils {
}
public static void xmlOptional(IBuffer result, String sp,
- String elementName, String value, Properties attributes) {
+ String elementName, @Nullable String value, Properties attributes) {
if (null != value) {
xmlRequired(result, sp, elementName, value, attributes);
}
}
public static void xmlRequired(IBuffer result, String sp,
- String elementName, String value, Properties attributes) {
+ String elementName, @Nullable String value, @Nullable Properties attributes) {
result.append(xml(sp, elementName, value, attributes));
}
diff --git a/src/test/java/org/testng/internal/MethodInstanceTest.java b/src/test/java/org/testng/internal/MethodInstanceTest.java
new file mode 100644
index 0000000..36bf2e1
--- /dev/null
+++ b/src/test/java/org/testng/internal/MethodInstanceTest.java
@@ -0,0 +1,557 @@
+package org.testng.internal;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.testng.Assert;
+import org.testng.IClass;
+import org.testng.IRetryAnalyzer;
+import org.testng.ITestClass;
+import org.testng.ITestNGMethod;
+import org.testng.annotations.Test;
+import org.testng.xml.XmlClass;
+import org.testng.xml.XmlInclude;
+import org.testng.xml.XmlTest;
+
+/**
+ * Unit tests for {@link MethodInstance}.
+ *
+ * @author Andreas Kluth
+ */
+public class MethodInstanceTest {
+
+ public static void main(String[] args) {
+ new MethodInstanceTest().sortByIndexSatisfiesContract();
+ }
+
+ @Test
+ public void sortByIndexSatisfiesContract() {
+
+ // Build a list of entries imposing the same behavior as the live suite, reduced to the
+ // minimum to create the same condition.
+ List<MethodInstance> methods = new ArrayList<MethodInstance>();
+ methods.add(buildMethodInstance("unittests", "StateTest", 1, "aCategorization"));
+ methods.add(buildMethodInstance("unittests", "StateTest", 1, "bCategorization"));
+ methods.add(buildMethodInstance("unittests", "StateTest", 1, "cCategorization"));
+ methods.add(buildMethodInstance("unittests", "StateTest", 1, "dCategorization"));
+ methods.add(buildMethodInstance("unittests", "StateTest", 1, "eCategorization"));
+ methods.add(buildMethodInstance("unittests", "StateTest", 1, "fCategorization"));
+ methods.add(buildMethodInstance("unittests", "StatusTest", 2, "aStatus"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildTestNgFactoryMethodInstance("unittests"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "aChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "bChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "cChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "dChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "eChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "fChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "gChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "eChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "hChangeTest"));
+ methods.add(buildMethodInstance("unittests", "ChangeTest", 3, "iChangeTest"));
+ methods.add(buildMethodInstance("unittests", "IdentifierClassTest", 4, "aIdentifier"));
+ methods.add(buildMethodInstance("unittests", "IdentifierClassTest", 4, "bIdentifier"));
+ methods.add(buildMethodInstance("unittests", "StatisticsTest", 0, "aStatistics"));
+ methods.add(buildMethodInstance("unittests", "StatisticsTest", 0, "bStatistics"));
+ methods.add(buildMethodInstance("unittests", "StatisticsTest", 0, "cStatistics"));
+
+ try {
+ Collections.sort(methods, MethodInstance.SORT_BY_INDEX);
+ }
+ catch (IllegalArgumentException ex) {
+ Assert.fail("Comparison method violates its general contract!");
+ }
+ }
+
+ private MethodInstance buildTestNgFactoryMethodInstance(String xmlTestName) {
+ TestClassStub testClass = new TestClassStub(new XmlTestStub(xmlTestName), null);
+ return new MethodInstance(new TestNGMethodStub(null, testClass));
+ }
+
+ private MethodInstance buildMethodInstance(String xmlTestName, String xmlClassName, int xmlClassIndex, String methodName) {
+ TestClassStub testClass = new TestClassStub(new XmlTestStub(xmlTestName), new XmlClassStub(xmlClassName, xmlClassIndex));
+ return new MethodInstance(new TestNGMethodStub(methodName, testClass));
+ }
+
+ public static class XmlClassStub extends XmlClass {
+ private static final long serialVersionUID = 1L;
+ private int index;
+ private String name;
+
+ public XmlClassStub(String name, int index) {
+ this.name = name;
+ this.index = index;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public List<XmlInclude> getIncludedMethods() {
+ return Collections.emptyList();
+ }
+ }
+
+ public static class XmlTestStub extends XmlTest {
+ private static final long serialVersionUID = 1L;
+ private String name;
+
+ public XmlTestStub(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+ }
+
+ public static class TestClassStub implements ITestClass {
+ private static final long serialVersionUID = 1L;
+
+ private XmlTest xmlTest;
+ private XmlClass xmlClass;
+
+ public TestClassStub(XmlTest xmlTest, XmlClass xmlClass) {
+ this.xmlTest = xmlTest;
+ this.xmlClass = xmlClass;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public XmlTest getXmlTest() {
+ return xmlTest;
+ }
+
+ @Override
+ public XmlClass getXmlClass() {
+ return xmlClass;
+ }
+
+ @Override
+ public String getTestName() {
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Class getRealClass() {
+ return null;
+ }
+
+ @Override
+ public void addInstance(Object instance) {
+ }
+
+ @Override
+ public Object[] getInstances(boolean reuse) {
+ return null;
+ }
+
+ @Override
+ public long[] getInstanceHashCodes() {
+ return null;
+ }
+
+ @Override
+ public int getInstanceCount() {
+ return 0;
+ }
+
+ @Override
+ public ITestNGMethod[] getTestMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getBeforeTestMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getAfterTestMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getBeforeClassMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getAfterClassMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getBeforeSuiteMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getAfterSuiteMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getBeforeTestConfigurationMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getAfterTestConfigurationMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getBeforeGroupsMethods() {
+ return null;
+ }
+
+ @Override
+ public ITestNGMethod[] getAfterGroupsMethods() {
+ return null;
+ }
+
+ }
+
+ public static class TestNGMethodStub implements ITestNGMethod {
+ private static final long serialVersionUID = 1L;
+ private TestClassStub testClassStub;
+ private String methodName;
+
+ public TestNGMethodStub(String methodName, TestClassStub testClassStub) {
+ this.methodName = methodName;
+ this.testClassStub = testClassStub;
+
+ }
+
+ @Override
+ public ITestNGMethod clone() {
+ return (TestNGMethodStub) this;
+ };
+
+ @Override
+ public int compareTo(Object o) {
+ return 0;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Class getRealClass() {
+ return null;
+ }
+
+ @Override
+ public ITestClass getTestClass() {
+ return testClassStub;
+ }
+
+ @Override
+ public void setTestClass(ITestClass cls) {
+ }
+
+ @Override
+ public Method getMethod() {
+ return null;
+ }
+
+ @Override
+ public String getMethodName() {
+ return methodName;
+ }
+
+ @Override
+ public Object[] getInstances() {
+ return null;
+ }
+
+ @Override
+ public Object getInstance() {
+ return null;
+ }
+
+ @Override
+ public long[] getInstanceHashCodes() {
+ return null;
+ }
+
+ @Override
+ public String[] getGroups() {
+ return null;
+ }
+
+ @Override
+ public String[] getGroupsDependedUpon() {
+ return null;
+ }
+
+ @Override
+ public String getMissingGroup() {
+ return null;
+ }
+
+ @Override
+ public void setMissingGroup(String group) {
+ }
+
+ @Override
+ public String[] getBeforeGroups() {
+ return null;
+ }
+
+ @Override
+ public String[] getAfterGroups() {
+ return null;
+ }
+
+ @Override
+ public String[] getMethodsDependedUpon() {
+ return null;
+ }
+
+ @Override
+ public void addMethodDependedUpon(String methodName) {
+ }
+
+ @Override
+ public boolean isTest() {
+ return false;
+ }
+
+ @Override
+ public boolean isBeforeMethodConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isAfterMethodConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isBeforeClassConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isAfterClassConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isBeforeSuiteConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isAfterSuiteConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isBeforeTestConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isAfterTestConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isBeforeGroupsConfiguration() {
+ return false;
+ }
+
+ @Override
+ public boolean isAfterGroupsConfiguration() {
+ return false;
+ }
+
+ @Override
+ public long getTimeOut() {
+ return 0;
+ }
+
+ @Override
+ public void setTimeOut(long timeOut) {
+ }
+
+ @Override
+ public int getInvocationCount() {
+ return 0;
+ }
+
+ @Override
+ public void setInvocationCount(int count) {
+ }
+
+ @Override
+ public int getSuccessPercentage() {
+ return 0;
+ }
+
+ @Override
+ public String getId() {
+ return null;
+ }
+
+ @Override
+ public void setId(String id) {
+ }
+
+ @Override
+ public long getDate() {
+ return 0;
+ }
+
+ @Override
+ public void setDate(long date) {
+ }
+
+ @Override
+ public boolean canRunFromClass(IClass testClass) {
+ return false;
+ }
+
+ @Override
+ public boolean isAlwaysRun() {
+ return false;
+ }
+
+ @Override
+ public int getThreadPoolSize() {
+ return 0;
+ }
+
+ @Override
+ public void setThreadPoolSize(int threadPoolSize) {
+ }
+
+ @Override
+ public boolean getEnabled() {
+ return false;
+ }
+
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ @Override
+ public void incrementCurrentInvocationCount() {
+ }
+
+ @Override
+ public int getCurrentInvocationCount() {
+ return 0;
+ }
+
+ @Override
+ public void setParameterInvocationCount(int n) {
+ }
+
+ @Override
+ public int getParameterInvocationCount() {
+ return 0;
+ }
+
+ @Override
+ public IRetryAnalyzer getRetryAnalyzer() {
+ return null;
+ }
+
+ @Override
+ public void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer) {
+ }
+
+ @Override
+ public boolean skipFailedInvocations() {
+ return false;
+ }
+
+ @Override
+ public void setSkipFailedInvocations(boolean skip) {
+ }
+
+ @Override
+ public long getInvocationTimeOut() {
+ return 0;
+ }
+
+ @Override
+ public boolean ignoreMissingDependencies() {
+ return false;
+ }
+
+ @Override
+ public void setIgnoreMissingDependencies(boolean ignore) {
+ }
+
+ @Override
+ public List<Integer> getInvocationNumbers() {
+ return null;
+ }
+
+ @Override
+ public void setInvocationNumbers(List<Integer> numbers) {
+ }
+
+ @Override
+ public void addFailedInvocationNumber(int number) {
+ }
+
+ @Override
+ public List<Integer> getFailedInvocationNumbers() {
+ return null;
+ }
+
+ @Override
+ public int getPriority() {
+ return 0;
+ }
+
+ @Override
+ public void setPriority(int priority) {
+ }
+
+ @Override
+ public XmlTest getXmlTest() {
+ return null;
+ }
+
+ @Override
+ public ConstructorOrMethod getConstructorOrMethod() {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> findMethodParameters(XmlTest test) {
+ return null;
+ }
+ }
+
+}
diff --git a/src/test/java/test/JUnit4Test.java b/src/test/java/test/JUnit4Test.java
index 4abbfa1..98b1f72 100644
--- a/src/test/java/test/JUnit4Test.java
+++ b/src/test/java/test/JUnit4Test.java
@@ -39,7 +39,7 @@ public class JUnit4Test extends BaseTest {
run();
String[] passed = JUnit4SampleSuite.EXPECTED;
- String[] failed = JUnit4Sample2.FAILED;
+ String[] failed = JUnit4SampleSuite.FAILED;
String[] skipped = JUnit4SampleSuite.SKIPPED;
verifyTests("Passed", passed, getPassedTests());
diff --git a/src/test/java/test/dataprovider/ExplicitDataProviderNameSample.java b/src/test/java/test/dataprovider/ExplicitDataProviderNameSample.java
new file mode 100644
index 0000000..089b13b
--- /dev/null
+++ b/src/test/java/test/dataprovider/ExplicitDataProviderNameSample.java
@@ -0,0 +1,16 @@
+package test.dataprovider;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class ExplicitDataProviderNameSample {
+
+ @Test(dataProvider="dp_name")
+ public void should_find_exactly_one_data_provider(int i) {}
+
+ @DataProvider(name="dp_name")
+ Object[][] whatever_implicit_name() {return new Object[][] {{1}};}
+
+ @DataProvider(name="whatever_explicit_name")
+ Object[][] dp_name() {return null;}
+}
\ No newline at end of file
diff --git a/src/test/java/test/dataprovider/ExplicitDataProviderNameTest.java b/src/test/java/test/dataprovider/ExplicitDataProviderNameTest.java
new file mode 100644
index 0000000..fba7bd8
--- /dev/null
+++ b/src/test/java/test/dataprovider/ExplicitDataProviderNameTest.java
@@ -0,0 +1,22 @@
+package test.dataprovider;
+
+import static org.testng.Assert.assertEquals;
+
+import org.testng.TestListenerAdapter;
+import org.testng.TestNG;
+import org.testng.annotations.Test;
+
+import test.SimpleBaseTest;
+
+public class ExplicitDataProviderNameTest extends SimpleBaseTest {
+
+ @Test(description = "TESTNG-576: Prefer DataProvider explicit name")
+ public void should_prefer_dataProvider_explicit_name() {
+ TestNG testng = create(ExplicitDataProviderNameSample.class);
+ TestListenerAdapter tla = new TestListenerAdapter();
+ testng.addListener(tla);
+ testng.run();
+
+ assertEquals(tla.getPassedTests().size(), 1, "All tests should success");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/test/junit4/JUnit4Sample2.java b/src/test/java/test/junit4/JUnit4Sample2.java
index 5ecfc0a..0209f82 100644
--- a/src/test/java/test/junit4/JUnit4Sample2.java
+++ b/src/test/java/test/junit4/JUnit4Sample2.java
@@ -1,6 +1,7 @@
package test.junit4;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Ignore;
import org.junit.Test;
@@ -11,7 +12,7 @@ import org.junit.Test;
public class JUnit4Sample2 {
public static final String[] EXPECTED = {"t2", "t4"};
- public static final String[] SKIPPED = {"t3"};
+ public static final String[] SKIPPED = {"t3", "ta"};
public static final String[] FAILED = {"tf"};
@Test
@@ -31,4 +32,9 @@ public class JUnit4Sample2 {
public void tf() {
Assert.fail("a test");
}
+
+ @Test
+ public void ta() {
+ Assume.assumeTrue(false);
+ }
}
diff --git a/src/test/java/test/junit4/JUnit4SampleSuite.java b/src/test/java/test/junit4/JUnit4SampleSuite.java
index d597a92..19e93b0 100644
--- a/src/test/java/test/junit4/JUnit4SampleSuite.java
+++ b/src/test/java/test/junit4/JUnit4SampleSuite.java
@@ -15,6 +15,6 @@ import org.junit.runners.Suite;
public class JUnit4SampleSuite {
public static final String[] EXPECTED = {"t1", "t2", "t4"};
- public static final String[] SKIPPED = {"t3"};
+ public static final String[] SKIPPED = {"t3", "ta"};
public static final String[] FAILED = {"tf"};
}
diff --git a/src/test/java/test/testng106/FailingSuiteFixture.java b/src/test/java/test/testng106/FailingSuiteFixture.java
index 8843dfa..2144de0 100644
--- a/src/test/java/test/testng106/FailingSuiteFixture.java
+++ b/src/test/java/test/testng106/FailingSuiteFixture.java
@@ -1,7 +1,5 @@
package test.testng106;
-import org.testng.Assert;
-import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
@@ -13,11 +11,6 @@ public class FailingSuiteFixture {
@BeforeSuite
public void failingBeforeSuite() {
- }
-
- @AfterSuite(alwaysRun=true)
- public void afterSuite() {
- System.out.println("Invocations:" + s_invocations + " must be 0");
- Assert.assertEquals(s_invocations, 0, "@BeforeSuite has failed. All tests should be skipped.");
+ throw new RuntimeException();
}
}
diff --git a/src/test/java/test/testng106/TestNG106.java b/src/test/java/test/testng106/TestNG106.java
new file mode 100644
index 0000000..92c883f
--- /dev/null
+++ b/src/test/java/test/testng106/TestNG106.java
@@ -0,0 +1,25 @@
+package test.testng106;
+
+import org.testng.Assert;
+import org.testng.TestNG;
+import org.testng.annotations.Test;
+import org.testng.xml.XmlSuite;
+import test.SimpleBaseTest;
+
+import java.util.Arrays;
+
+public class TestNG106 extends SimpleBaseTest {
+ @Test
+ public void testFailingBeforeSuiteShouldSkipAllTests() throws Exception {
+ TestNG tng = create();
+ XmlSuite s = createXmlSuite("TESTNG-106");
+ createXmlTest(s, "myTest1", FailingSuiteFixture.class.getName(), Test1.class.getName());
+ createXmlTest(s, "myTest2", Test1.class.getName());
+ createXmlTest(s, "myTest3", Test2.class.getName());
+ createXmlTest(s, "myTest-last", Test2.class.getName());
+ tng.setXmlSuites(Arrays.asList(s));
+ tng.setVerbose(3);
+ tng.run();
+ Assert.assertEquals(FailingSuiteFixture.s_invocations, 0, "@BeforeSuite has failed. All tests should be skipped.");
+ }
+}
diff --git a/src/test/java/test/testng106/testng-106.xml b/src/test/java/test/testng106/testng-106.xml
deleted file mode 100644
index 25b6bf9..0000000
--- a/src/test/java/test/testng106/testng-106.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
-
-<suite name="TESTNG-106" verbose="3">
- <test name="myTest1">
- <classes>
- <class name="test.testng106.FailingSuiteFixture" />
- <class name="test.testng106.Test1"/>
- </classes>
- </test>
- <test name="myTest2">
- <classes>
- <class name="test.testng106.Test1"/>
- </classes>
- </test>
- <test name="myTest3">
- <classes>
- <class name="test.testng106.Test2"/>
- </classes>
- </test>
- <test name="myTest-last">
- <classes>
- <class name="test.testng106.Test2"/>
- </classes>
- </test>
-</suite>
\ No newline at end of file
diff --git a/src/test/java/test/testng387/FailedDPTest.java b/src/test/java/test/testng387/FailedDPTest.java
index 317d3bc..72cd496 100644
--- a/src/test/java/test/testng387/FailedDPTest.java
+++ b/src/test/java/test/testng387/FailedDPTest.java
@@ -1,16 +1,12 @@
package test.testng387;
-import org.testng.Assert;
-import org.testng.ITestContext;
-import org.testng.ITestNGMethod;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
/**
* test for http://jira.opensymphony.com/browse/TESTNG-387
* The invocation-numbers logic in failed.xml is wrong for dataprovider and parallel=true
@@ -22,7 +18,7 @@ import java.util.List;
public class FailedDPTest {
// prime numbers < 10
- private List<Integer> primes = new ArrayList<Integer>();
+ static List<Integer> primes = new ArrayList<Integer>();
public FailedDPTest(){
primes.add(2);
primes.add(3);
@@ -54,35 +50,4 @@ public class FailedDPTest {
}
}
- /**
- * validates that the failed invoc number are the correct ones, ie the prime numbers.
- * @param ctx
- */
- @AfterClass(alwaysRun=true)
- public void check(ITestContext ctx){
- ITestNGMethod testMethod = getMethod(ctx, "isNotPrime");
-
- List<Integer> failed = testMethod.getFailedInvocationNumbers();
- if (failed.size() != primes.size()){
- throw new Error();
- }
- for (Integer num : primes) {
- Assert.assertTrue(failed.contains(num),num+" should be present to be retried.It is not.");
- }
- }
-
-
-
- private ITestNGMethod getMethod(ITestContext ctx, String methodName) {
-
- ITestNGMethod method = null;
- for (int i = 0; i < ctx.getAllTestMethods().length; i++) {
- method = ctx.getAllTestMethods()[i];
- if (method.getMethodName().equals(methodName)) {
- return method;
- }
- }
- throw new RuntimeException("test case creation bug.");
- }
-
}
diff --git a/src/test/java/test/testng387/TestNG387.java b/src/test/java/test/testng387/TestNG387.java
new file mode 100644
index 0000000..f0130c3
--- /dev/null
+++ b/src/test/java/test/testng387/TestNG387.java
@@ -0,0 +1,38 @@
+package test.testng387;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.ITestContext;
+import org.testng.ITestNGMethod;
+import org.testng.TestListenerAdapter;
+import org.testng.TestNG;
+import org.testng.annotations.Test;
+import test.SimpleBaseTest;
+
+public class TestNG387 extends SimpleBaseTest {
+ @Test
+ public void testInvocationCounterIsCorrectForMethodWithDataProvider() throws Exception {
+ final TestNG tng = create(FailedDPTest.class);
+ tng.setThreadCount(1);
+ tng.setParallel("false");
+ tng.setPreserveOrder(true);
+ final TestListenerAdapter tla = new TestListenerAdapter();
+ tng.addListener(tla);
+ tng.run();
+
+ final List<ITestContext> contexts = tla.getTestContexts();
+ Assert.assertNotNull(contexts);
+ Assert.assertEquals(contexts.size(), 1);
+ final ITestContext context = contexts.iterator().next();
+ Assert.assertNotNull(context);
+ final ITestNGMethod[] methods = context.getAllTestMethods();
+ Assert.assertNotNull(methods.length);
+ Assert.assertEquals(methods.length, 1);
+
+ List<Integer> failed = methods[0].getFailedInvocationNumbers();
+ Collections.sort(failed); // Is that correct? Shouldn't be already sorted by Invoker (like DataProvider parameters)
+ Assert.assertEquals(failed, FailedDPTest.primes, "FailedInvocationNumbers mismatch");
+ }
+}
diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml
index ca8b566..34da7d0 100644
--- a/src/test/resources/testng.xml
+++ b/src/test/resources/testng.xml
@@ -121,6 +121,7 @@
<class name="test.testng234.PolymorphicFailureTest" />
<class name="test.reports.FailedReporterTest" />
<class name="test.reports.ReporterLogTest" />
+ <class name="test.testng387.TestNG387"/>
</classes>
</test>
@@ -462,6 +463,7 @@
<class name="test.dataprovider.IterableTest" />
<class name="test.dataprovider.ConfigurationAndDataProvidersTest" />
<class name="test.dataprovider.BooleanTest" />
+ <class name="test.dataprovider.ExplicitDataProviderNameTest" />
<class name="test.dataprovider.MethodTest"/>
<class name="test.dataprovider.StaticDataProviderSampleTest" />
<class name="test.dataprovider.UnnamedDataProviderTest" />
@@ -731,5 +733,11 @@
</classes>
</test>
+ <test name="TESTNG-106">
+ <classes>
+ <class name="test.testng106.TestNG106"/>
+ </classes>
+ </test>
+
</suite>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git
More information about the pkg-java-commits
mailing list