<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>web2.0goodies.com &#187; testng</title>
	<atom:link href="http://web2.0goodies.com/blog/category/testng/feed/" rel="self" type="application/rss+xml" />
	<link>http://web2.0goodies.com/blog</link>
	<description>Tips, Tricks, and How To's for Web 2.0</description>
	<lastBuildDate>Tue, 03 Jan 2012 05:34:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>MultiThreaded TestNG, Surefire Craziness.</title>
		<link>http://web2.0goodies.com/blog/java/multithreaded-testng-surefire-craziness/</link>
		<comments>http://web2.0goodies.com/blog/java/multithreaded-testng-surefire-craziness/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 18:53:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[testng]]></category>

		<guid isPermaLink="false">http://web2.0goodies.com/blog/?p=25</guid>
		<description><![CDATA[The Setup Maven 2.0.9 Surefire 2.4.3 TestNG version 5.8 The Craziness If you annotate a method to have an invocationCount of 2, and a threadPoolSize of 2, and your test fails in an @BeforeMethod or an @AfterMethod when run by surefire, the test run count reported by surefire will be inaccurate. Significantly innacurate at times. [...]]]></description>
			<content:encoded><![CDATA[<h1>The Setup</h1>
<p>Maven 2.0.9<br />
Surefire 2.4.3<br />
TestNG version 5.8</p>
<h1>The Craziness</h1>
<p>If you annotate a method to have an invocationCount of 2, and a threadPoolSize of 2, and your test fails in an @BeforeMethod or an @AfterMethod when run by surefire, the test run count reported by surefire will be inaccurate.  Significantly innacurate at times. </p>
<p>For example:</p>
<p><code><br />
package com.infusion.crm.application;</p>
<p>import org.testng.annotations.AfterMethod;<br />
import org.testng.annotations.BeforeMethod;<br />
import org.testng.AssertJUnit;<br />
import org.testng.annotations.Test;</p>
<p>/**<br />
 * Created by IntelliJ IDEA.<br />
 * User: joey<br />
 * Date: Jun 29, 2009<br />
 * Time: 3:19:13 PM<br />
 * To change this template use File | Settings | File Templates.<br />
 */<br />
public class TestThreadPoolSize {<br />
    @BeforeMethod<br />
    public void before(){<br />
        AssertJUnit.assertFalse(true);<br />
    }</p>
<p>    @Test<br />
    public void test1(){<br />
        AssertJUnit.assertFalse(true);<br />
    }<br />
}</p>
<p></code></p>
<p>Returns the following from maven test:</p>
<p><code><br />
-------------------------------------------------------<br />
 T E S T S<br />
-------------------------------------------------------<br />
Running TestSuite<br />
Tests run: 8, Failures: 1, Errors: 0, Skipped: 7, Time elapsed: 10.298 sec <<< FAILURE!</p>
<p>Results :</p>
<p>Failed tests:<br />
  before(com.infusion.crm.application.TestThreadPoolSize)</p>
<p>Tests run: 8, Failures: 1, Errors: 0, Skipped: 7</p>
<p></code></p>
<p>This problem is also manifested if you create an AnnotationTransformer that forces the invocationCount and threadPoolSize of a test to both be greater then 1.</p>
<p>This bug is only manifested when multiple threads are used.  If you set the invocation count to 20 and the thread pool size to 1, the bug does not appear.</p>
<p>Sometimes it is unpredictable and worse then just 2x the right number of tests. I ran a test, with 9 methods, and 4 threads, and a very exhaustive @BeforeMethod that takes several seconds to run.  It failed repeatedly and said: 142 test run, 3 failed, 139 skipped.</p>
]]></content:encoded>
			<wfw:commentRss>http://web2.0goodies.com/blog/java/multithreaded-testng-surefire-craziness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

