<?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>Sander Nieuwenhuizen &#187; Java</title>
	<atom:link href="http://blog.time-to-play.net/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.time-to-play.net</link>
	<description>Agile &#039;n&#039; stuff</description>
	<lastBuildDate>Sat, 26 Mar 2011 15:16:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Organizing test code in Java</title>
		<link>http://blog.time-to-play.net/2010/11/11/organizing-test-code-in-java/</link>
		<comments>http://blog.time-to-play.net/2010/11/11/organizing-test-code-in-java/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 22:07:25 +0000</pubDate>
		<dc:creator>sander</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.time-to-play.net/?p=131</guid>
		<description><![CDATA[A short while back I started to work with Ruby on Rails. Incredible fun and inspiring and one of the (many) things I like is the distinction Rails by default creates of the different levels of test scopes. It has separate folders to store unit,...]]></description>
			<content:encoded><![CDATA[<p>A short while back I started to work with Ruby on Rails. Incredible fun and inspiring and one of the (many) things I like is the distinction Rails by default creates of the different levels of test scopes. It has separate folders to store unit, functional and performance tests. I still also do Java projects.</p>
<p>Now in Java &#8211; and using the Maven default folder layout &#8211; you get one folder for storing your production code (<code>src/main/java</code>) and one for your test code (<code>src/test/java</code>). That got me to thinking to apply Rails&#8217; way to structure your Java test suite.</p>
<h3>Please please, gimme the good stuff!</h3>
<p>Yeah yeah, getting there. So, what you need to be doing is the following:</p>
<ol>
<li>Under the default <code>src/test/java</code> folder create a folder per test level you want. I have separated folders for unit, functional and integration tests</li>
<li>Alter your Maven pom.xml to contain the following:</li>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.time-to-play.net/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.time-to-play.net/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://blog.time-to-play.net/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.time-to-play.net/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="xml" style="font-family:monospace;">...
<span class="sc3"><span class="re1">&lt;build<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;testSourceDirectory<span class="re2">&gt;</span></span></span>src/test/java/unit<span class="sc3"><span class="re1">&lt;/testSourceDirectory<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;plugins<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;plugin<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;groupId<span class="re2">&gt;</span></span></span>org.codehaus.mojo<span class="sc3"><span class="re1">&lt;/groupId<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;artifactId<span class="re2">&gt;</span></span></span>build-helper-maven-plugin<span class="sc3"><span class="re1">&lt;/artifactId<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;version<span class="re2">&gt;</span></span></span>1.5<span class="sc3"><span class="re1">&lt;/version<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;executions<span class="re2">&gt;</span></span></span>
        <span class="sc3"><span class="re1">&lt;execution<span class="re2">&gt;</span></span></span>
          <span class="sc3"><span class="re1">&lt;id<span class="re2">&gt;</span></span></span>add-test-source<span class="sc3"><span class="re1">&lt;/id<span class="re2">&gt;</span></span></span>
          <span class="sc3"><span class="re1">&lt;phase<span class="re2">&gt;</span></span></span>generate-sources<span class="sc3"><span class="re1">&lt;/phase<span class="re2">&gt;</span></span></span>
          <span class="sc3"><span class="re1">&lt;goals<span class="re2">&gt;</span></span></span>
            <span class="sc3"><span class="re1">&lt;goal<span class="re2">&gt;</span></span></span>add-test-source<span class="sc3"><span class="re1">&lt;/goal<span class="re2">&gt;</span></span></span>
          <span class="sc3"><span class="re1">&lt;/goals<span class="re2">&gt;</span></span></span>
          <span class="sc3"><span class="re1">&lt;configuration<span class="re2">&gt;</span></span></span>
            <span class="sc3"><span class="re1">&lt;sources<span class="re2">&gt;</span></span></span>
              <span class="sc3"><span class="re1">&lt;source<span class="re2">&gt;</span></span></span>src/test/java/functional<span class="sc3"><span class="re1">&lt;/source<span class="re2">&gt;</span></span></span>
              <span class="sc3"><span class="re1">&lt;source<span class="re2">&gt;</span></span></span>src/test/java/integration<span class="sc3"><span class="re1">&lt;/source<span class="re2">&gt;</span></span></span>
            <span class="sc3"><span class="re1">&lt;/sources<span class="re2">&gt;</span></span></span>
          <span class="sc3"><span class="re1">&lt;/configuration<span class="re2">&gt;</span></span></span>
        <span class="sc3"><span class="re1">&lt;/execution<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;/executions<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;/plugin<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/plugins<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/build<span class="re2">&gt;</span></span></span>
...</pre></div></div>
<li>Now you can add test classes into the appropriate location. If you run <code>mvn test</code> they will be contained in the test run. Also you can get Eclipse to understand this separation. Just running <code>mvn eclipse:eclipse</code> will get you the following:</li>
<p><a href="http://blog.time-to-play.net/wp-content/uploads/2010/11/test-code-organization.png"><img class="aligncenter size-full wp-image-134" title="test-code-organization" src="http://blog.time-to-play.net/wp-content/uploads/2010/11/test-code-organization.png" alt="" width="203" height="134" /></a></p>
<h3>Conclusion</h3>
<p>Cramming everything in a single test folder can get really messy. From the outside it&#8217;s hard to see what the test scope of a class is. Sometimes you see this scope included in the class name, or even in the package definition. I don&#8217;t like that all too much. Now it&#8217;s immediately clear what the scope of your tests is by looking at the folder they&#8217;re in. I got some positive responses from different people. Hope this helps you too, let me know what you think!</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.time-to-play.net/2010/11/11/organizing-test-code-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What a day</title>
		<link>http://blog.time-to-play.net/2009/07/07/what-a-day/</link>
		<comments>http://blog.time-to-play.net/2009/07/07/what-a-day/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 14:10:41 +0000</pubDate>
		<dc:creator>sander</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[golf]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://blog.time-to-play.net/?p=76</guid>
		<description><![CDATA[Yesterday morning I had my GVB exam (Golf Vaardigheids Bewijs). In The Netherlands you need this to prove you can play golf. If you achieve it, you can then play golf pretty much on any course you like. After the first bit (theoretic part), you...]]></description>
			<content:encoded><![CDATA[<p>Yesterday morning I had my GVB exam (Golf Vaardigheids Bewijs). In The Netherlands you need this to prove you can play golf. If you achieve it, you can then play golf pretty much on any course you like.</p>
<p>After the first bit (theoretic part), you would go for the hands on action. First up, theory. 20 questions are up, of which you need to have 15 right. Most of them were rather easy, especially if you&#8217;d have practiced a lot of exam questions. After about 20 minutes I was the 2nd person leaving the room. Out on the terrace which filled up with more contestants there was heavy discussion about the questions. My dear friend N stepped outside 5 mins later. We both felt quite confident about it. Then the news came&#8230; I was invited to take the practical exam as I scored 20/20! Friend N scored 18 right. We went in different pairs to the championship course of golf course Naarderbos. There we played hole 1, 2, 4 and 5. Of the best 3 holes played you were allowed in total 10 above par. So if you played really well (which N did <img src='http://blog.time-to-play.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) hole 4 was just for fun. My play was not too bad, but not that smooth either. The lady I played with unfortunately did not play that well. During hole 2 I realized that if I kept playing the way I did, I would surely pass. Some lousy and some magnificent shots later the verdict came: I passed! Triple yay <img src='http://blog.time-to-play.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  My lady partner however did not.</p>
<p>Back on the terrace N came with his good news. After a nice lunch out in the open, we played the par 3 course. A nice track of 9 holes , not as much fun though as the 18 holes. We both played 38 strokes, 7 below our freshly acquired handicap of 36.</p>
<p>After finishing enjoying a nice beer I went to a presentation of <a href="http://www.larsvonkconsultancy.nl/" target="_blank">Lars Vonk</a> about Test Driven Development (TDD in short). He explained very clearly about this concept: first write your functional oriented test case, then write your code. He described a tool called Fitnesse, in which you can create these tests using pretty much natural language. I&#8217;ve heard about TDD before but now it triggered something inside me. Stuff to think about. It&#8217;s on a higher level compared to unit testing. With unit testing you can only verify so much, but you do not test if the software integrates well. With TDD you write actual integration tests, focusing on the bigger picture. Furthermore, you can also reuse already written tests. What more do you need in life <img src='http://blog.time-to-play.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.time-to-play.net/2009/07/07/what-a-day/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

