<?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>Software on a smoking barrel &#187; TestNG</title>
	<atom:link href="http://www.margelatu.org/tag/testng/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.margelatu.org</link>
	<description></description>
	<lastBuildDate>Thu, 06 Oct 2011 14:01:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Java code coverage reports in Eclipse</title>
		<link>http://www.margelatu.org/2009/06/25/java-code-coverage-reports-in-eclipse/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=java-code-coverage-reports-in-eclipse</link>
		<comments>http://www.margelatu.org/2009/06/25/java-code-coverage-reports-in-eclipse/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 11:38:35 +0000</pubDate>
		<dc:creator>Ionut-Maxim Margelatu</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[code coverage]]></category>
		<category><![CDATA[eclemma]]></category>
		<category><![CDATA[TestNG]]></category>

		<guid isPermaLink="false">http://margelatu.org/?p=52</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.margelatu.org/2009/06/25/java-code-coverage-reports-in-eclipse/' addthis:title='Java code coverage reports in Eclipse '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>A part of our team&#8217;s &#8220;definition of done&#8221; is having unit-tests in place and, unofficially, a minimum of 80% code coverage. Our Maven-based build process runs the tests and then creates code coverage reports in HTML format, that we can then consult in the documentation that Maven generates. Along with other reports, this helps us [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.margelatu.org/2009/06/25/java-code-coverage-reports-in-eclipse/' addthis:title='Java code coverage reports in Eclipse ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.margelatu.org/2009/06/25/java-code-coverage-reports-in-eclipse/' addthis:title='Java code coverage reports in Eclipse '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>A part of our team&#8217;s &#8220;definition of done&#8221; is having unit-tests in place and, unofficially, a minimum of 80% code coverage. Our Maven-based build process runs the tests and then creates code coverage reports in HTML format, that we can then consult in the documentation that Maven generates. Along with other reports, this helps us get a clear picture of where our code is in terms of stability and quality.</p>
<p>This is all great ; but when you&#8217;re in the middle of a task and you write unit-tests, it&#8217;s quite tedious to run the build and then open the HTML coverage report just to monitor your code coverage. I spend about 80% of my time for a task in Eclipse : opening and activating tasks with Mylyn, coding, writing unit-tests, running unit-tests and so on. This is why for me it made sense to seek out a way to monitor the code coverage in Eclipse.</p>
<p>After a bit of googling, I found a Java code coverage plug-in for Eclipse : <a href="http://www.eclemma.org/" target="_blank">EclEmma</a>. As you can see from its name, it&#8217;s based on the EMMA Java code coverage tool. Here&#8217;s a list with its main features :</p>
<ul>
<li>a <em>coverage</em> mode in which applications launched or unit tests are instrumented and measured</li>
<li>coverage overview : a coverage view containing a report on the source code coverage values at project-level, package-level and class-level</li>
<li>source highlighting in the Java code editor using customizable colors</li>
<li>customizable coverage counters</li>
<li>multiple coverage sessions and session merging</li>
<li>importing EMMA coverage data files</li>
<li>exporting to EMMA coverage data, XML and HTML</li>
</ul>
<p>The easiest way to install it is through the update site : <a href="http://update.eclemma.org/" target="_blank">http://update.eclemma.org</a>. After the installation, you will notice a new launch mode appearing in the Eclipse toolbar, called <em><strong>Coverage</strong></em>, similar to the <em><strong>Run</strong></em> and <em><strong>Debug</strong></em> modes. This new mode allows you to run coverage reports on applications or unit-tests just like you would before run those applications or unit-tests.</p>
<p>In a project I&#8217;m currently working on, our server-side unit tests are written using TestNG. From Eclipse, I can run one or multiple TestNG units using the Eclipse TestNG plug-in, so I can easily verify that my code passes the unit tests. I have defined a launch configuration for each server-side project which runs all of the unit-tests. To check out the code coverage for those tests, all I have to do is create a coverage configuration and make sure that I select the source code folders to be instrumented.</p>
<p>I created a sample Java-Maven-TestNG project and added to it a simple class called <strong><em>ShoppingCartImpl</em></strong> along with a TestNG test class. Here&#8217;s how it looks :</p>
<div id="attachment_55" class="wp-caption aligncenter" style="width: 1034px"><img src="http://margelatu.org/wp-content/uploads/2009/06/eclemma_sample_cart_source_code-1024x587.png" alt="Source code of a very basic shopping cart" title="Source code of a very basic shopping cart" width="1024" height="587" class="size-large wp-image-55" /><p class="wp-caption-text">Source code of a very basic shopping cart</p></div>
<p>As you can see, this is a very basic class. Now on to configuring the coverage settings ; this is a simple matter of clicking on the <strong>Coverage</strong> button in Eclipse&#8217;s toolbar and selecting the menu option <strong>Coverage Configurations&#8230;</strong>. This opens up the coverage configuration window, as seen below :</p>
<div id="attachment_56" class="wp-caption aligncenter" style="width: 956px"><img src="http://margelatu.org/wp-content/uploads/2009/06/eclemma_sample_coverage_configuration.png" alt="Creating a new EclEmma coverage configuration" title="Creating a new EclEmma coverage configuration" width="946" height="808" class="size-full wp-image-56" /><p class="wp-caption-text">Creating a new EclEmma coverage configuration</p></div>
<p>All I have to do is select the TestNG test suite that I want to run and check the source folders that are relevant to code coverage. I&#8217;m using Maven and all my source code is in <em>src/main/java</em> so I only select that folder. I click <strong>Apply</strong> and then I can finally run the coverage report. I click on the <strong>Coverage</strong> button and theTestNG configuration is executed and the coverage report is available :</p>
<div id="attachment_57" class="wp-caption aligncenter" style="width: 1034px"><img src="http://margelatu.org/wp-content/uploads/2009/06/eclemma_sample_coverage_after_first_run-1024x587.png" alt="Code coverage report after a first run" title="Code coverage report after a first run" width="1024" height="587" class="size-large wp-image-57" /><p class="wp-caption-text">Code coverage report after a first run</p></div>
<p>In the bottom of the Eclipse window, you get a clear picture of the code coverage. As you can see, the are reports at project, package and class level, which also show up in the package explorer, in the left. To enable the decorators in the package explorer, go to the Eclipse menu and select <em>Preferences</em> -&gt; <em>General</em> -&gt; <em>Appearance</em> -&gt; <em>Label decorations</em>, then make sure that the <strong><em>Java Code Coverage</em></strong> label decoration option is checked.</p>
<p>Another interesting feature of EclEmma is that after the code coverage instrumentation you can actually see the coverage in the source code. As you can see, each line relevant to the coverage report is marked with a color. Green is for 100% branch coverage, yellow is for some branch coverage and red for no coverage at all. The shopping cart has quite a low code coverage so I did shape it up. After a bit of fiddling with the code, I get a 100% code coverage and a very nice report :</p>
<p><div id="attachment_58" class="wp-caption aligncenter" style="width: 1034px"><img src="http://margelatu.org/wp-content/uploads/2009/06/eclemma_sample_full_coverage-1024x587.png" alt="The ShoppingCart class with 100% code coverage" title="The ShoppingCart class with 100% code coverage" width="1024" height="587" class="size-large wp-image-58" /><p class="wp-caption-text">The ShoppingCart class with 100% code coverage</p></div> <!-- PHP 5.x --></p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.margelatu.org/2009/06/25/java-code-coverage-reports-in-eclipse/' addthis:title='Java code coverage reports in Eclipse ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.margelatu.org/2009/06/25/java-code-coverage-reports-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Categorizing tests in Java</title>
		<link>http://www.margelatu.org/2009/03/27/categorizing-tests-in-java/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=categorizing-tests-in-java</link>
		<comments>http://www.margelatu.org/2009/03/27/categorizing-tests-in-java/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 10:26:17 +0000</pubDate>
		<dc:creator>Ionut-Maxim Margelatu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[component tests]]></category>
		<category><![CDATA[system tests]]></category>
		<category><![CDATA[test categories]]></category>
		<category><![CDATA[TestNG]]></category>
		<category><![CDATA[unit tests]]></category>

		<guid isPermaLink="false">http://margelatu.org/?p=21</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.margelatu.org/2009/03/27/categorizing-tests-in-java/' addthis:title='Categorizing tests in Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>When you write developer tests, you start with just a few and as your code base gets larger and larger, so does the number of tests. The build starts to take more and more time and soon you avoid running the build as often as possible. If you get to this, then you need to [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.margelatu.org/2009/03/27/categorizing-tests-in-java/' addthis:title='Categorizing tests in Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://www.margelatu.org/2009/03/27/categorizing-tests-in-java/' addthis:title='Categorizing tests in Java '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>When you write developer tests, you start with just a few and as your code base gets larger and larger, so does the number of tests. The build starts to take more and more time and soon you avoid running the build as often as possible. If you get to this, then you need to categorize your tests.</p>
<h3>How do I do it ?</h3>
<p>First, stop calling every developer test a <em>unit test</em>.</p>
<p>Second, categorizing your <em>formerly-known-as-unit-tests</em> tests means you separate them into different layers based on external dependencies, complexity, time of execution. There are 3 layers of developer tests : unit tests, component tests, system tests.</p>
<h4>Categories</h4>
<h5>Unit tests</h5>
<p>Unit tests are run against objects without any external dependencies. Any external dependency is mocked and the unit test concentrates only on the object you wrote. This is why unit tests are usually simpler to write and take less time to execute.</p>
<h5>Component tests</h5>
<p>Component tests validate multiple objects with external dependencies and their interaction. This means that you deal with databases, file systems, HTTP connections and so on, and with the interaction between your objects (<em>the component</em>) and the external systems. Component tests tend to be more complex than unit tests, they take more time to write and more time to execute.</p>
<h5>System tests</h5>
<p>When you want to test your application from one end to the other, you write system tests. They verify your application <strong>as if</strong> an user would use the application, that is <a href="http://www.ibm.com/developerworks/java/library/j-cq10316/index.html" target="_blank">they <em>mimic</em> one</a>.</p>
<h4>I have my categories, now what ?</h4>
<p>Now it&#8217;s time to update your build process.</p>
<h5>Update the build process</h5>
<p>You have 3 categories of developer tests : unit test, component tests and system tests. Because unit tests run fast, you can choose to run them during each build and during each CI build. In contrast, since component tests and system tests take much more time to execute, you can choose to skip them during a regular CI build and run them less often.</p>
<h5>Setting up a staged build</h5>
<p>In his articles about Continuous Integration, Martin Fowler suggests to <a href="ttp://martinfowler.com/articles/continuousIntegration.html#KeepTheBuildFast" target="_blank">keep the build fast</a> by setting up <strong>a staged build</strong>.<br />
The basic idea is that by setting up a staged build (a 2 phases build) you can achieve a compromise between execution time and testing thoroughness. The developers need a feedback on their commit, so the testing process needs to be as thorough as possible, but the feedback must be delivered as quickly as possible because you don&#8217;t want to keep the developers waiting while the build is running.</p>
<p>To accomplish this, you can set up two builds : <strong>a commit build</strong> &#8211; the build that everyone executes before committing code &#8211; and <strong>a secondary build</strong> &#8211; a full build.</p>
<h6>The commit build</h6>
<p>The commit build <strong>has to be run</strong> by everyone before committing code. During this build, only unit tests are executed, so the build doesn&#8217;t take a lot of time ; on the other hand, this also means that the application is not tested at a higher level.<br />
This build is also run by the CI system after each commit.</p>
<h6>The secondary build</h6>
<p>The secondary build is a full build, it runs all of the tests &#8211; unit tests, component tests, system tests. This means it takes a lot longer to complete, but on the other hand it gives you a complete feedback on your application.</p>
<p>The secondary build is run by the CI system. Depending on the time it takes to complete the secondary build, you can have the CI system to run it after each successful commit build or at regular time intervals.</p>
<h3>Categorizing tests in Java</h3>
<p>I use <a href="http://testng.org" target="_blank">TestNG</a> to write developer tests for my Java code. The reason for this is that it has some features that I haven&#8217;t found elsewhere yet, so I stick to it. One of these features is, <em>coincidentally</em>, the ability to define and use <a href="http://testng.org/doc/documentation-main.html#test-groups" target="_blank">test groups</a>. At its core, it&#8217;s all about being able to define groups of tests and to run one or more groups of tests during a testing session or during a build.</p>
<p>The approach I took on a project was to write the tests using TestNG and to divide them into three TestNG test groups, corresponding to the test categories I described earlier. First, I declared some constants for the groups :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> GROUP_UNIT_TEST <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;unit-test&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> GROUP_COMPONENT <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;component&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> GROUP_SYSTEM <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;system&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Then whenever I added a test method, I would assign it to a test group. For instance, unit tests :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> GROUP_UNIT_TEST <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testAdaptNullList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span>
@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> GROUP_UNIT_TEST <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testAdaptList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Component tests would look very similar :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> GROUP_COMPONENT <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testSqlConnection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span>
@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> GROUP_COMPONENT <span style="color: #009900;">&#125;</span>, dependsOnMethods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;testSqlConnection&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testGetTargetData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the code block above, you can notice another nice feature of TestNG : <a href="http://testng.org/doc/documentation-main.html#dependent-methods" target="_blank">dependent methods</a>. In the test above, the test method <strong>testSqlConnection</strong> is run first. If it fails, the dependent method <strong>testGetTargetData</strong> is skipped.<br />
With TestNG&#8217;s dependent methods mechanism, you can have some methods from your tests depend on other methods to make sure a certain number of test methods have completed and succeeded before running more test methods. This feature makes sure you don&#8217;t waste time running certain tests which will fail for sure if other tests already failed.</p>
<p>And now for some system tests :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> GROUP_SYSTEM <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testGetFilters<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span>
&nbsp;
@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> GROUP_SYSTEM <span style="color: #009900;">&#125;</span>, dependsOnMethods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;testGetFilters&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testGetFiltersPeriods<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span>
&nbsp;
@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> GROUP_SYSTEM <span style="color: #009900;">&#125;</span>, dependsOnMethods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;testGetFilters&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testGetFiltersCallCenter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
...
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Once the tests are in place, I can configure the builds accordingly. I can configure the commit build, based on Maven, to run only unit tests :</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-surefire-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>unit-test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The secondary build, on the other hand, can run all the tests :</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-surefire-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>unit-test,component,system<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Easy, right ? TestNG is integrated nicely with Maven using the <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html" target="_blank">Maven Surefire Plugin</a>.<br />
TestNG is also <a href="http://testng.org/doc/eclipse.html" target="_blank">integrated with Eclipse</a> so that you can run tests or groups of tests from Eclipse while you&#8217;re coding. If you&#8217;re an Ant guy, check out the <a href="http://testng.org/doc/ant.html" target="_blank">TestNG Ant task</a>. And another thing if you&#8217;re an Ant guy : switch to Maven.<!-- PHP 5.x --></p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.margelatu.org/2009/03/27/categorizing-tests-in-java/' addthis:title='Categorizing tests in Java ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.margelatu.org/2009/03/27/categorizing-tests-in-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Object Caching 447/511 objects using disk: basic

Served from: www.margelatu.org @ 2011-10-16 06:17:04 -->
