<?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>Gojko Adzic &#187; tdd</title>
	<atom:link href="http://gojko.net/tag/tdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://gojko.net</link>
	<description>Building software that matters</description>
	<lastBuildDate>Fri, 12 Mar 2010 07:59:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Two new BDD workshops available</title>
		<link>http://gojko.net/2009/12/14/two-new-bdd-workshops-available/</link>
		<comments>http://gojko.net/2009/12/14/two-new-bdd-workshops-available/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 15:43:58 +0000</pubDate>
		<dc:creator>gojko</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[workshops]]></category>

		<guid isPermaLink="false">http://gojko.net/?p=1490</guid>
		<description><![CDATA[I&#8217;m launching two new Behaviour-Driven Development workshops in late January. 
Introduction to BDD is an intensive one day workshop which introduces behaviour-driven development to developers, business analysts and testers. The optional programming module is offered in Java or .NET, with Cucumber to automate BDD scenarios.
Hands-on BDD with Cucumber  is a three day workshop which [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m launching two new Behaviour-Driven Development workshops in late January. </p>
<p><a href="http://neuri.co.uk/training/introduction-to-bdd">Introduction to BDD</a> is an intensive one day workshop which introduces behaviour-driven development to developers, business analysts and testers. The optional programming module is offered in Java or .NET, with Cucumber to automate BDD scenarios.</p>
<p><a href="http://neuri.co.uk/training/hands-on-bdd-with-cucumber">Hands-on BDD with Cucumber</a>  is a three day workshop which immerses the participants into a project driven by Specification by Example and Behaviour-Driven Development. The workshop is adjusted to fit your business domain and particular needs, so that the participants get real-world experience and instant benefits. It is combines the <a href="http://neuri.co.uk/training/introduction-to-bdd/">Introduction to BDD</a>, a day of working on a realistic domain example taken from your recent project or a future phase of a project, and a day of programming exercises for test automation developers. During the workshop, we use Cucumber to manage BDD Scenarios. The programming modules can be either in Java or .NET. </p>
<p>These two workshops are offered at a 20% discount for all bookings made before 31st January 2010. For more information on these and my other workshops, check out the <a href="http://neuri.co.uk/training">training</a> page. </p>
<p>Both workshops are offered as on-site training only (there are no public workshops scheduled at this time). <a href="http://neuri.co.uk/contact/">Contact my company, Neuri Ltd</a> for more information and to book a workshop. </p>
]]></content:encoded>
			<wfw:commentRss>http://gojko.net/2009/12/14/two-new-bdd-workshops-available/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Improving testing practices at Google</title>
		<link>http://gojko.net/2009/12/07/improving-testing-practices-at-google/</link>
		<comments>http://gojko.net/2009/12/07/improving-testing-practices-at-google/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 10:09:27 +0000</pubDate>
		<dc:creator>gojko</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[xpday]]></category>

		<guid isPermaLink="false">http://gojko.net/2009/12/07/improving-testing-practices-at-google/</guid>
		<description><![CDATA[Mark Striebeck from Google opened XPDay 2009 today with a talk titled &#8220;Developer testing, from the dark ages to the age of enlightenment&#8221;. Suggesting that software testing is today in a renaissance stage, Striebeck said that the community is now rediscovering &#8220;ancient&#8221; practices. Most things we use in testing today were invented a long time [...]]]></description>
			<content:encoded><![CDATA[<p>Mark Striebeck from Google opened XPDay 2009 today with a talk titled &#8220;Developer testing, from the dark ages to the age of enlightenment&#8221;. Suggesting that software testing is today in a renaissance stage, Striebeck said that the community is now rediscovering &#8220;ancient&#8221; practices. Most things we use in testing today were invented a long time ago, and then forgotten, said Striebeck. In the last fifteen years, the community started rediscovering these practices and people were focused on advancing the art, not teaching. As a result, there are many good testing practices out there but having testable code is still more an art than science, according to Striebeck.</p>
<p>Google had a team of Test Mercenaries, who joined different teams for a short period of time to help them with testing. In most cases, they could see what was wrong after a few days and started helping the teams, but the effort wasn&#8217;t a success. When they left, teams would not improve significantly.  Striebeck said that testing &#8220;wasn&#8217;t effective to teach&#8221;. Knowing what makes a good test often relied on personal opinion and gut-feel. Doing what they often do in similar situations, Striebeck said that they decided to collect data. The things that they were interested in were figuring out the characteristics of good tests and testable code and how to know in the first place that a test is effective. They decided to use a return-on-investment criteria: low investment (easy to write, easy to maintain), high return (alert to problems when it fails). According to Striebeck, Google spends $100M per year on test automation, and wanted an answer whether they are actually getting a good return on that investment. They estimated that a bug found during TDD costs $5 to fix, which surges to $50 for tests during a full build and $500 during an integration test. It goes to $5000 during a system test. Fixing bugs earlier would save them an estimated $160M per year.</p>
<p>To collect data, they set up a code-metrics storage to put all test execution analytics in a single place. Striebeck pointed out that Google has a single code repository, which is completely open to all of the 10000 developers. Although all systems are released independently (with release release cycles randing from a week to a month), everything is built from HEAD without any binary releases, and the repository receives several thousand changes per day with spikes of 20+ changes per minute. This resulted in 40+ millions of tests executed per day from a continuous integration service plus IDE and command line runs, they collected test results, coverage, buld time, binary size, static analysis and complexity analysis. Instead of anyone deciding whether a test is good or not, the system observed what people do with tests to rank them. They looked into what a developer does after a test fails. If the code was changed or added, the test was marked as good. If people changes the test code when it fails, it was marked as a bad test (especially if everyone is changing it). This means that the test was brittle and has a high maintenance cost. They also measured which tests are ignored in releases and which tests often failed inthe continuous build and weren&#8217;t executed during development. </p>
<p>The first step was to provide developers reactive feedback on tests. For example, the system suggested deleting tests that teams spent loads of time maintaining. They then collected metrics on whether the people actually acted on suggestions or not. The system also provided metrics to tech leads and managers to show how teams are doing with tests.</p>
<p>The second step, which is in progress at the moment, is to find patterns and indicators. As they now have identified lots of good and bad tests, the system is looking for common characteristics among them. Once these patterns are collected, algorithms will be designed to identify good and bad tests, and manually calibrated by experts. </p>
<p>The third step will be to provide constructive feedback to developers, telling developers how to improve tests, what tests to write an dhow to make the code more testable. </p>
<p>The fourth step in this effort will be to provide prognostic feedback, analysing code evolution patterns and warn developers that their change might result in a particular problem later on. </p>
<p><i>I will be covering XpDay 2009 on this blog in detail. Subscribe to my <a href="/feed">RSS feed</a> to get notified when I post new articles.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://gojko.net/2009/12/07/improving-testing-practices-at-google/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>FitNesse book now free online</title>
		<link>http://gojko.net/2009/12/07/fitnesse-book-now-free-online/</link>
		<comments>http://gojko.net/2009/12/07/fitnesse-book-now-free-online/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 01:09:36 +0000</pubDate>
		<dc:creator>gojko</dc:creator>
				<category><![CDATA[fitnesse]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[fitsharp]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://gojko.net/?p=1448</guid>
		<description><![CDATA[As of now, the second edition of Test Driven .NET Development with FitNesse is free online. You can download the full PDF version or read the book online in HTML at http://gojko.net/fitnesse. 
What&#8217;s new in this version?
Since the book was originally released, both FitNesse and the .NET FIT test runner were improved significantly. All the [...]]]></description>
			<content:encoded><![CDATA[<p>As of now, the second edition of Test Driven .NET Development with FitNesse is free online. You can download the full PDF version or read the book online in HTML at <a href="http://gojko.net/fitnesse">http://gojko.net/fitnesse</a>. </p>
<h2>What&#8217;s new in this version?</h2>
<p>Since the book was originally released, both FitNesse and the .NET FIT test runner were improved significantly. All the examples in this book are now updated to be compatible with the latest releases of FitNesse (20091121) and FitSharp (1.4). I re-wrote parts that are no longer applicable to the new FitSharp test runner, especially around Cell Operators. In a classic example of self-inflicted scope creep, I also wrote a new chapter on using domain objects directly.</p>
<p>I also changed the tool used for assembling the book. Instead of Apache FOP, I used XEP which will hopefully make the layout a bit better. Fonts (especially the code font) were also changed to make the book easier to read.</p>
<h2>What about the paperback</h2>
<p>I will make the paperback available soon. At the moment, the second edition is only available online.</p>
]]></content:encoded>
			<wfw:commentRss>http://gojko.net/2009/12/07/fitnesse-book-now-free-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dark arts of TDD explained</title>
		<link>http://gojko.net/2009/11/20/dark-arts-of-tdd-explained/</link>
		<comments>http://gojko.net/2009/11/20/dark-arts-of-tdd-explained/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 09:58:49 +0000</pubDate>
		<dc:creator>gojko</dc:creator>
				<category><![CDATA[book reviews]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[mocking]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://gojko.net/?p=1396</guid>
		<description><![CDATA[Growing Object Oriented Software, Guided by Tests, by Steve Freeman and Nat Pryce is a TDD book, but unlike any other on the market today. First of all, the book deals mostly with advanced unit testing topics, such as designing tests for readability and mocking, and addresses many common stumbling points that people experience with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/0321503627?ie=UTF8&#038;tag=swingwiki-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321503627"><img align="left" border="0" src="/images/51fQ0%2B5W%2BkL._SL160_.jpg" style="margin:5px 5px 5px 5px"/></a><img src="http://www.assoc-amazon.com/e/ir?t=swingwiki-20&#038;l=as2&#038;o=1&#038;a=0321503627" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><a href="http://www.amazon.com/gp/product/0321503627?ie=UTF8&#038;tag=swingwiki-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321503627">Growing Object Oriented Software, Guided by Tests</a>, by <a href="http://www.m3p.co.uk/blog">Steve Freeman</a> and <a href="http://www.natpryce.com/">Nat Pryce</a> is a TDD book, but unlike any other on the market today. First of all, the book deals mostly with advanced unit testing topics, such as designing tests for readability and mocking, and addresses many common stumbling points that people experience with unit testing a few years after they started their journey, such as applying unit testing in multi-threaded and asynchronous environments. Second, it explains and demonstrates in practice the dynamics of designing software through TDD, which is still a dark art for many programmers. And third, it gives the reader insight into Freeman&#8217;s and Pryce&#8217;s brains, which is why this book is a must-read for anyone serious about unit testing, even to people that have been doing it in the last century. <span id="more-1396"></span></p>
<p>Given the authors&#8217; backgrounds, it&#8217;s not surprising that this book has a lot to say about using mock object libraries. Mock objects are arguably the most misunderstood and misused concept in software development today, so this book should be a valuable resource for most software development teams. In the part dealing with mock objects you will find strategies for using them successfully for software design, guidelines what to mock and what not to mock and lots of examples how all that looks in code.</p>
<p>The book isn&#8217;t written in the usual imperative way (“you should use this because of&#8230;”) but reads much more as an experience report (“we use this because of”). This might be unusual at first but I really like it, as it puts the things into a much more different perspective. Many of the topics addressed by this book are quite controversial and the authors have wisely chosen the voice to avoid any notion of preaching. I found myself disagreeing with parts, especially around bundling acceptance and end-to-end testing together. However, as the material doesn&#8217;t preach but tell what the authors are thinking about, this did not bother me at all.</p>
<p>All in all, an excellent book. <a href="http://www.amazon.com/gp/product/0321503627?ie=UTF8&#038;tag=swingwiki-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321503627">Grab a copy from Amazon now.</a></p>
<p>Here are some related links: </p>
<ul>
<li><a href="http://gojko.net/2009/09/21/mocks-are-not-about-isolation-but-about-responsibilities/">notes from Steve Freeman&#8217;s presentation on mock objects at CITCON Europe 09</a></li>
<li><a href="http://www.growing-object-oriented-software.com/">book web site</a></li>
<li><a href="http://www.m3p.co.uk/blog">Steve Freeman&#8217;s blog</a></li>
<li><a href="http://www.natpryce.com/">Nat Pryce&#8217;s blog</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://gojko.net/2009/11/20/dark-arts-of-tdd-explained/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mockito in six easy examples</title>
		<link>http://gojko.net/2009/10/23/mockito-in-six-easy-examples/</link>
		<comments>http://gojko.net/2009/10/23/mockito-in-six-easy-examples/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 13:41:39 +0000</pubDate>
		<dc:creator>gojko</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mocking]]></category>
		<category><![CDATA[mockito]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://gojko.net/?p=1346</guid>
		<description><![CDATA[Mockito is a fantastic mock library for Java. I&#8217;m fascinated by how easy it is to use, compared to other things out there both in the Java and .NET world. Here is everything you need to know to get started in six really easy examples.
First of all, get mockito from http://mockito.org/. Almost everything really interesting [...]]]></description>
			<content:encoded><![CDATA[<p>Mockito is a fantastic mock library for Java. I&#8217;m fascinated by how easy it is to use, compared to other things out there both in the Java and .NET world. Here is everything you need to know to get started in six really easy examples.<span id="more-1346"></span></p>
<p>First of all, get mockito from <a href="http://mockito.org">http://mockito.org/</a>. Almost everything really interesting can be imported with the org.mockito.Mockito class (or a static import of its methods, which I&#8217;ll use in this post). So let&#8217;s get right into it. </p>
<p>To create a stub (or a mock), use mock(class). Then use when(mock).thenReturn(value) to specify the stub value for a method. If you specify more than one value, they will be returned in sequence until the last one is used, after which point the last specified value gets returned. (So to have a method return the same value always, just specify it once). For example:</p>
<pre style="margin-bottom:10px">
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import java.util.Iterator;
import org.junit.Test;
....
	@Test
	public void iterator_will_return_hello_world(){
		//arrange
		Iterator i=mock(Iterator.class);
		when(i.next()).thenReturn("Hello").thenReturn("World");
		//act
		String result=i.next()+" "+i.next();
		//assert
		assertEquals("Hello World", result);
	}
</pre>
<p>This example creates a mock iterator and makes it return &#8220;Hello&#8221; the first time method next() is called. Calls after that return &#8220;World&#8221;. Then we can run normal assertions. </p>
<p>Stubs can also return different values depending on arguments passed into the method. For example:</p>
<pre style="margin-bottom:10px">
	@Test
	public void with_arguments(){
		Comparable c=mock(Comparable.class);
		when(c.compareTo("Test")).thenReturn(1);
		assertEquals(1,c.compareTo("Test"));
	}
</pre>
<p>This creates a stub Comparable object and returns 1 if it is compared to a particular String value (&#8220;Test&#8221; in this case). If the method has arguments but you really don&#8217;t care what gets passed or cannot predict it, use anyInt() (and alternative values for other types). For example:</p>
<pre style="margin-bottom:10px">
	@Test
	public void with_unspecified_arguments(){
		Comparable c=mock(Comparable.class);
		when(c.compareTo(anyInt())).thenReturn(-1);
		assertEquals(-1,c.compareTo(5));
	}
</pre>
<p>This stub comparable returns -1 regardless of the actual method argument. With void methods, this gets a bit tricky as you can&#8217;t use them in the when() call. The alternative syntax is doReturn(result).when(mock_object).void_method_call(); Instead of returning, you can also use .thenThrow() or doThrow() for void methods. For example:</p>
<pre style="margin-bottom:10px">
	@Test(expected=IOException.class)
	public void OutputStreamWriter_rethrows_an_exception_from_OutputStream()
		throws IOException{
		OutputStream mock=mock(OutputStream.class);
		OutputStreamWriter osw=new OutputStreamWriter(mock);
		doThrow(new IOException()).when(mock).close();
		osw.close();
	}
</pre>
<p>This example throws an IOException when the mock OutputStream close method is called. We verify easily that the OutputStreamWriter rethrows the exception of the wrapped output stream. To verify actual calls to underlying objects (typical mock object usage), we can use verify(mock_object).method_call; For example:</p>
<pre style="margin-bottom:10px">
	@Test
	public void OutputStreamWriter_Closes_OutputStream_on_Close()
		 throws IOException{
		OutputStream mock=mock(OutputStream.class);
		OutputStreamWriter osw=new OutputStreamWriter(mock);
		osw.close();
		verify(mock).close();
	}
</pre>
<p>This example will verify that OutputStreamWriter propagates the close method call to the wrapped output stream. You can use arguments on methods and matchers such as anyInt() similar to the previous example. Note that you can&#8217;t mix literals and matchers, so if you have multiple arguments they all have to be either literals or matchers. use eq(value) matcher to convert a literal into a matcher that compares on value. Mockito comes with lots of matchers already built in, but sometimes you need a bit more flexibility. For example, OutputStreamWriter will buffer output and then send it to the wrapped object when flushed, but we don&#8217;t know how big the buffer is upfront. So we can&#8217;t use equality matching. However, we can supply our own matcher:</p>
<pre style="margin-bottom:10px">
	@Test
	public void OutputStreamWriter_Buffers_And_Forwards_To_OutputStream()
		throws IOException{
		OutputStream mock=mock(OutputStream.class);
		OutputStreamWriter osw=new OutputStreamWriter(mock);
		osw.write('a');
		osw.flush();
		// can't do this as we don't know how long the array is going to be
		// verify(mock).write(new byte[]{'a'},0,1);

		BaseMatcher<byte []> arrayStartingWithA=new BaseMatcher</byte><byte []>(){
			@Override
			public void describeTo(Description description) {
				// nothing
			}
			// check that first character is A
			@Override
			public boolean matches(Object item) {
				byte[] actual=(byte[]) item;
				return actual[0]=='a';
			}
		};
		// check that first character of the array is A, and that the other two arguments are 0 and 1
		verify(mock).write(argThat(arrayStartingWithA), eq(0),eq(1));
	}
</byte></pre>
<p>That&#8217;s it &#8211; all you need to know to get started. Now go forth and refactor all that easymock ugliness from your projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://gojko.net/2009/10/23/mockito-in-six-easy-examples/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
