<?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>Femgineer &#187; Software Testing</title>
	<atom:link href="http://femgineer.com/category/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://femgineer.com</link>
	<description>Coder. Speaker. Writer.</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:27:04 +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>Cowboy Coders</title>
		<link>http://femgineer.com/2009/10/cowboy-coders/</link>
		<comments>http://femgineer.com/2009/10/cowboy-coders/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 17:22:49 +0000</pubDate>
		<dc:creator>Poornima</dc:creator>
				<category><![CDATA[Software Testing]]></category>

		<guid isPermaLink="false">http://femgineer.com/?p=281</guid>
		<description><![CDATA[Despite being from Texas, I&#8217;m not a cowgal coder, but this cartoon made me laugh out loud the minute I read it:

 Tweet This Post]]></description>
			<content:encoded><![CDATA[<p>Despite being from Texas, I&#8217;m not a cowgal coder, but this cartoon made me laugh out loud the minute I read it:</p>
<p><img class="aligncenter size-full wp-image-280" title="picture-6" src="http://femgineer.com/wp-content/uploads/2009/10/picture-6.png" alt="picture-6" width="415" height="786" /></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Cowboy+Coders+http://tinyurl.com/3ez2fvg" title="Post to Twitter"><img class="nothumb" src="http://femgineer.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Cowboy+Coders+http://tinyurl.com/3ez2fvg" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://femgineer.com/2009/10/cowboy-coders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test more preach less</title>
		<link>http://femgineer.com/2009/08/test-more-preach-less/</link>
		<comments>http://femgineer.com/2009/08/test-more-preach-less/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 16:25:07 +0000</pubDate>
		<dc:creator>Poornima</dc:creator>
				<category><![CDATA[Software Testing]]></category>

		<guid isPermaLink="false">http://femgineer.com/?p=209</guid>
		<description><![CDATA[
For the past three years I&#8217;ve been trying to emphasize and build unit tests at Mint.com.  I&#8217;ve tried TDD and some other approaches but nothing has kept up pace with an agile-like speed of development.  The article  Is Unit Testing Doomed? talks about the issues that developers have today with all the different philosophies of ]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-215" title="picture-7" src="http://femgineer.com/wp-content/uploads/2009/08/picture-7.png" alt="picture-7" width="493" height="379" /></p>
<p>For the past three years I&#8217;ve been trying to emphasize and build unit tests at Mint.com.  I&#8217;ve tried TDD and some other approaches but nothing has kept up pace with an agile-like speed of development.  The article  <a href="http://www.javaworld.com/javaworld/jw-08-2008/jw-08-unit-testing-doomed.html" target="_blank">Is Unit Testing Doomed?</a> talks about the issues that developers have today with all the different philosophies of unit testing, and why so many opt out of doing it.  Instead of forsaking unit testing because I couldn&#8217;t find the right methodology to suite my needs, I decided to come up with my own home grown version of it.</p>
<p>My approach is to design the entire project&#8217;s front and back-end&#8217;s set of interactions, then the data model to represent the back-end.  I then break the design apart into components that I plan on implementing.  After implementing each piece I write some unit tests for the apis I have developed.  I do this for each component or logical unit I am developing.  I use stubs to avoid class dependencies and focus on the class I am testing.</p>
<p>Since I&#8217;m operating in an agile-like environment the design is sure to change, in the event that it does I haven&#8217;t wasted a whole lot of time by writing test cases up front using TDD.  I can go in and quickly modify a few test cases that are impacted by the new design, and add additional test cases to handle the new design.  They key is that I&#8217;m not writing unit tests to fit my design or testing at the very end when I have very little to no time, and there is too much to test.  I&#8217;m writing test cases as I&#8217;m developing.  This has a couple benefits: first, its faster to spot bugs that new code might be causing in older code because I have test cases for my older code, hence I&#8217;m not breaking old functionality.  Second, when I unit test right after I&#8217;ve written a new component I&#8217;m forced to think about corner cases that might happen in the beginning of the development cycle rather than the end.  This also improves the overall design of my code and the feature.  If I have time prior to a release, I will add test cases as I fix bugs.  This is how I&#8217;ve incrementally built up a regressions suite.</p>
<p>I think developers should face the responsibility of unit testing their code, instead of offloading all testing to QA.  While you might not be able to think of 100% of the cases, flushing out simple error cases and thinking through a few corner cases at least handle some of the bugs that will come your way.  Unit testing is not a substitute for integration testing, but given the time for system setup and tear down unit testing at least keeps pace with daily development.  You can focus on integration testing once you&#8217;ve got the feature set completed, or also do it as part of your unit testing.  The point is to consider the philosophies of testing, and try to adapt them to meet your needs.  If writing test cases is the primary battle, focus more on meeting your teams developmental needs and less on being dogmatic about the current testing trends.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Test+more+preach+less+http://tinyurl.com/3j39dlv" title="Post to Twitter"><img class="nothumb" src="http://femgineer.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Test+more+preach+less+http://tinyurl.com/3j39dlv" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://femgineer.com/2009/08/test-more-preach-less/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trade-offs in Unit Testing &#8211; Part II Stubs</title>
		<link>http://femgineer.com/2008/10/trade-offs-in-unit-testing-part-ii-stubs/</link>
		<comments>http://femgineer.com/2008/10/trade-offs-in-unit-testing-part-ii-stubs/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 08:13:54 +0000</pubDate>
		<dc:creator>Poornima</dc:creator>
				<category><![CDATA[Software Testing]]></category>

		<guid isPermaLink="false">http://femgineer.com/?p=82</guid>
		<description><![CDATA[After spending a couple days implementing test cases using Mock objects, I switched to testing using stubs, because I still needed to verify the functionality of the code.
It took me only a few hours to write the test cases I needed using stubs, and with and IDE it’s even easier. But I don’t think its ]]></description>
			<content:encoded><![CDATA[<p>After spending a couple days implementing test cases using Mock objects, I switched to testing using stubs, because I still needed to verify the functionality of the code.</p>
<p>It took me only a few hours to write the test cases I needed using stubs, and with and IDE it’s even easier. But I don’t think its a fair assessment to compare using Mocks to Stubs because each tool is used for a different purpose (behavioral vs. functional).</p>
<p>However, I did notice one very obvious disadvantage to using stubs; if your application is dynamic and the functionality is changing test cases become brittle quickly, and require you to add additional members or functions.</p>
<p>But I would still advocate using stubs in writing test cases, because of the simplicity involved in writing them, being able to abstract away or limit dependent classes.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Trade-offs+in+Unit+Testing+%26%238211%3B+Part+II+Stubs+http://tinyurl.com/3urlqqu" title="Post to Twitter"><img class="nothumb" src="http://femgineer.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Trade-offs+in+Unit+Testing+%26%238211%3B+Part+II+Stubs+http://tinyurl.com/3urlqqu" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://femgineer.com/2008/10/trade-offs-in-unit-testing-part-ii-stubs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trade-offs in Unit Testing &#8211; Part III Stub Objects</title>
		<link>http://femgineer.com/2008/06/70/</link>
		<comments>http://femgineer.com/2008/06/70/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 23:12:10 +0000</pubDate>
		<dc:creator>Poornima</dc:creator>
				<category><![CDATA[Software Testing]]></category>

		<guid isPermaLink="false">http://femgineer.com/?p=70</guid>
		<description><![CDATA[I understand that no one likes to write test cases. For most developers its tied with debugging as their least favorite activity, because they just want to focus on algorithms, and writing code; thats the fun stuff. But I don’t think developers understand the importance of writing test cases. The more test cases you write ]]></description>
			<content:encoded><![CDATA[<p>I understand that no one likes to write test cases. For most developers its tied with debugging as their least favorite activity, because they just want to focus on algorithms, and writing code; thats the fun stuff. But I don’t think developers understand the importance of writing test cases. The more test cases you write the more time you have to develop! I know it sounds counter-intuitive. But the reasoning is the more test cases you write, the fewer bugs you have to fix, which also means less time spent debugging as well! Writing quality code frees up time to work on more new and exciting projects. </p>
<p>Recently at Mint I noticed I was getting bombarded with bugs everyday I walked into the office. And they were all for features that I had written over 6 months ago! But I hadn’t bothered to test them out, because I was being assigned new feature requests everyday, and writing code for new features was much more glamorous to writing test cases for old features. So one evening I decided enough is enough! I was tired of sitting in my cube every week and devoting more than half a day to fixing and debugging bugs! What was my solution? Unit-testing using stubs. I took each key feature that I was responsible for a created a test suite for them. For each suite I outlined the basic unit test cases, corner cases, and test cases for bugs I had experienced. My next dilemma was how to write the unit test cases without needing a Spring Application Context, and without needing to generate test data or use a database… enter Stubs.</p>
<p>When you have a code base as large as Mint’s you are bound to run into some interdependencies even when unit testing. But the principle of unit testing is to focus on one or a limited number of classes or key functionality. The best way to do this is to use a stub. A stub acts as a substitute for another class. The easiest way to implement it is to extend a parent class or implement an interface, and then provide a basic implementation of the class by specifying simple return values for the methods (i.e. there is hardly any logic in the methods). You then replace the class-under-test’s dependency with a stub class. </p>
<p>For example, all my Alert classes had a dependence to an AlertDao class (the AlertDao class is the class that stores data base objects). Since I didn’t want to my unit test cases to depend on a data base I abstracted away the AlertDao Class using an AlertDaoStub. The AlertDaoStub contained the same methods as the AlertDao, but they methods had very simple return values. In place of using an AlertDao I used the AlertDaoStub; this change was transparent to the Alert class.</p>
<blockquote><p>e.g. Implementation of the Stub class</p>
<p>// class-under-test<br />
AlertManager am = new AlertManager();<br />
// stub class that extends a parent class<br />
AlertDao ad = new AlertDaoStub();<br />
// replace AlertDao with AlertDaoStub<br />
am.setAlertDao(ad);</p>
<p>public class AlertManager {<br />
    private AlertDao _myAlertDao;</p>
<p>    public void setAlertDao(AlertDao ad) {<br />
        this._myAlertDao = ad;<br />
    }<br />
}</p>
<p>// This can either be a public class or a private inner class depending on how much it needs to</p></blockquote>
<blockquote><p>// be re-used</p></blockquote>
<blockquote><p>public class AlertDaoStub extends AlertDao {</p>
<p>    public Set&lt;Alert&gt; getAlerts(User u) {<br />
        return new HashSet&lt;Alert&gt;();<br />
    } </p>
<p>    public void setAlerts(User u, Set&lt;Alert&gt; alerts) {<br />
        user.setAlerts(alerts); <br />
    }<br />
}</p></blockquote>
<p>While this technique required some refactoring, and one long night of coding, I believe in the long run I will have contributed to the quality of the Mint code base, and saved myself countless hours of debugging.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Trade-offs+in+Unit+Testing+%26%238211%3B+Part+III+Stub+Objects+http://tinyurl.com/3udgvoe" title="Post to Twitter"><img class="nothumb" src="http://femgineer.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Trade-offs+in+Unit+Testing+%26%238211%3B+Part+III+Stub+Objects+http://tinyurl.com/3udgvoe" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://femgineer.com/2008/06/70/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Part II &#8211; Trade-off to using Mock Objects</title>
		<link>http://femgineer.com/2008/06/part-ii-trade-off-to-using-mock-objects/</link>
		<comments>http://femgineer.com/2008/06/part-ii-trade-off-to-using-mock-objects/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 22:27:08 +0000</pubDate>
		<dc:creator>Poornima</dc:creator>
				<category><![CDATA[Software Testing]]></category>

		<guid isPermaLink="false">http://femgineer.com/?p=68</guid>
		<description><![CDATA[I spent a week testing the security framework at Mint.  I chose Mock objects as the methodology for testing because I wanted to test that when a user logs in a certain set of methods is called (i.e. there was clearly an expected behavior I was aiming to test).  Being very familiar with the architecture ]]></description>
			<content:encoded><![CDATA[<p>I spent a week testing the security framework at Mint.  I chose Mock objects as the methodology for testing because I wanted to test that when a user logs in a certain set of methods is called (i.e. there was clearly an expected behavior I was aiming to test).  Being very familiar with the architecture of the code base I knew the levels of hierarchy that needed to be traversed for a user to successfully log in, and thus my test case consisted of verifying the correct behavior at each of those levels.  While I was able to successfully use Mocks to create the test suite I wanted, I came across several key trade-offs of behavioral testing using Mocks.</p>
<p>1. You must have a decent understand of the use case you are testing; you must know which methods and classes are pivotal to the test case, and which can be abstracted away using expectations.</p>
<p>2. Using expectations can be a time-saver because unlike stubs you can just specify what the return value of the method should be, how many times it should be called, and what if any parameters are expected.  This limits the amount of test code you need to write.  However, the class methods need to be fairly deterministic, meaning they must always return the same result given a certain set of inputs.  </p>
<p>3. Mocks are perfect when it comes to testing classes with limited functionality or that are isolated from other classes.  Interdependencies between classes makes using Mocks a nuisance.  If the given class you are testing has a lot of dependencies amongst other classes then it requires you to create Mocks for those classes as well.  This can bloat your test code, and take a longer time to test, because now you must program for the dependent classes and setup their expected behavior as well.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Part+II+%26%238211%3B+Trade-off+to+using+Mock+Objects+http://tinyurl.com/43cekqk" title="Post to Twitter"><img class="nothumb" src="http://femgineer.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Part+II+%26%238211%3B+Trade-off+to+using+Mock+Objects+http://tinyurl.com/43cekqk" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://femgineer.com/2008/06/part-ii-trade-off-to-using-mock-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trade-offs in Unit Testing &#8211; Part I Mock Objects</title>
		<link>http://femgineer.com/2008/03/trade-offs-in-unit-testing-part-i-mock-objects/</link>
		<comments>http://femgineer.com/2008/03/trade-offs-in-unit-testing-part-i-mock-objects/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 06:43:21 +0000</pubDate>
		<dc:creator>Poornima</dc:creator>
				<category><![CDATA[Software Testing]]></category>

		<guid isPermaLink="false">http://femgineer.com/?p=60</guid>
		<description><![CDATA[One of my many roles at Mint.com is the lead test engineer. I believe I was appointed this role by our CEO, because I am pretty good at thinking through use cases, setting up testing infrastructure, and being diligent about having unit tests for our core functionality and making sure that they pass daily.
Lately, we’ve ]]></description>
			<content:encoded><![CDATA[<p>One of my many roles at Mint.com is the lead test engineer. I believe I was appointed this role by our CEO, because I am pretty good at thinking through use cases, setting up testing infrastructure, and being diligent about having unit tests for our core functionality and making sure that they pass daily.</p>
<p>Lately, we’ve noticed that our test cases are brittle, and have poor coverage mostly because of feature growth. My boss proposed that we seek a new approach to how we write and manage our unit test cases that is scalable and easy to practice under time constraints. So today, during one of the most productive and interested meetings I’ve ever had in my career, we discussed the trade-offs between using Stubs versus Mock Objects for unit testing. Our discussion was directed by the following requirements:</p>
<p>1. Little to no use of a database</p>
<p>2. Test logic at the controller level (servlet/ JSP) and at the service level.</p>
<p>3. Simple template that can be re-used to write additional test cases and doesn’t require complete knowledge of back-end architecture.</p>
<p>As a homework assignment for the meeting I read Martin Fowler’s “Mocks Aren’t Stubs”; Mackinnon, Freeman, and Craig’s “Endo Testing: Unit Testing With Mock Objects”; and a few sections from the book “Test Drive Development”. I thought each of these resources presented interesting insights into testing in general.</p>
<p>Fowler’s article introduced me to behavioral testing, which is the concept that in an application engineers should test the interaction amongst classes. Contrast this to functional verification, which is inputing data and then verifying the end results for accuracy.</p>
<p>This is the first time I had been presented with the concept of behavioral testing, and I realize it makes a lot of sense for a scalable web application, because the order and sequence of method invocations is just as important as data accuracy. Running code off of various servers, and across different layers has a huge impact on the data, so its just as important to test the interaction as it is to verify the data values.</p>
<p>Mock objects are the means by which engineers can do behavioral testing, because Mocks are programmed using expectations. Expectations are either a list of methods to call sometimes in a particular sequence, and/or values that a method may return. When a test case is run it simulates the behavior in a system using the Mock objects in place of POJOs, and verifies that the expectations were met.</p>
<p>Thus, Mocks do not contain all the functionality or attributes of a POJO, but serve in place of them by containing enough knowledge in the form of abstractions to test the interactions of the application.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Trade-offs+in+Unit+Testing+%26%238211%3B+Part+I+Mock+Objects+http://tinyurl.com/3nwvack" title="Post to Twitter"><img class="nothumb" src="http://femgineer.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Trade-offs+in+Unit+Testing+%26%238211%3B+Part+I+Mock+Objects+http://tinyurl.com/3nwvack" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://femgineer.com/2008/03/trade-offs-in-unit-testing-part-i-mock-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

