<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Making the Complex Simple &#187; Automation</title>
	<atom:link href="http://simpleprogrammer.com/category/testing/automation/feed/" rel="self" type="application/rss+xml" />
	<link>http://simpleprogrammer.com</link>
	<description>Software Development from John Sonmez&#039;s Perspective</description>
	<lastBuildDate>Tue, 07 Feb 2012 17:47:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='simpleprogrammer.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Making the Complex Simple &#187; Automation</title>
		<link>http://simpleprogrammer.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://simpleprogrammer.com/osd.xml" title="Making the Complex Simple" />
	<atom:link rel='hub' href='http://simpleprogrammer.com/?pushpress=hub'/>
		<item>
		<title>Getting up to BAT: Building a True DSL</title>
		<link>http://simpleprogrammer.com/2011/05/14/getting-up-to-bat-building-a-true-dsl/</link>
		<comments>http://simpleprogrammer.com/2011/05/14/getting-up-to-bat-building-a-true-dsl/#comments</comments>
		<pubDate>Sun, 15 May 2011 03:24:52 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2011/05/14/getting-up-to-bat-building-a-true-dsl/</guid>
		<description><![CDATA[If you’ve made it this far with your BAT implementation, you have finally arrived. Not to say that you’ll ever be done expanding your automation framework and building and improving your BATs, but you are at the point of having a mature usable BAT framework and you can be proud of that accomplishment. If you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1329&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you’ve made it this far with your BAT implementation, you have finally arrived.</p>
<p>Not to say that you’ll ever be done expanding your automation framework and building and improving your BATs, but you are at the point of having a mature usable BAT framework and you can be proud of that accomplishment.</p>
<p>If you truly want to see where the rabbit hole goes though… Read on</p>
<h2>Taking it to 11</h2>
<p><a href="http://complextosimple.files.wordpress.com/2011/05/spinal_tap_but_it_goes_to_eleven.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="spinal_tap_but_it_goes_to_eleven" border="0" alt="spinal_tap_but_it_goes_to_eleven" src="http://complextosimple.files.wordpress.com/2011/05/spinal_tap_but_it_goes_to_eleven_thumb.jpg?w=485&#038;h=273" width="485" height="273" /></a></p>
<p>If you have designed a good automation framework for writing your BATs, you will most likely have created an internal domain specific language (DSL).</p>
<p>What is an internal DSL?</p>
<p>Basically it is a set of APIs and rules built in another language that function as their own language.</p>
<p>You might have some code that looks like this:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:08f381ea-bda8-4f72-ab40-6ac923941fc7" class="wlWriterEditableSmartContent">
<pre style="white-space:normal;">
<pre class="brush: csharp; pad-line-numbers: true;">
Pages.Login.Goto();
Pages.Login.LoginWithDefaultUser();
Pages.Customers.Goto();
Pages.Customers.AddNewCustomer();
</pre>
</pre>
</div>
<p>&#160;</p>
<p>You can see how this code is really looking like a language itself.&#160; It is hard to tell if this code is even C# or Java.</p>
<p>This is a good example of an internal DSL.</p>
<p>If we were to take this same section of a BAT test and write it as an external DSL, it might look something like this:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:521b3b0f-ee9e-4256-8083-4b36a0085593" class="wlWriterEditableSmartContent">
<pre style="white-space:normal;">
<pre class="brush: plain;">
LOGIN WITH DEFAULT-USER
ADD-CUSTOMER WITH DEFAULT-CUSTOMER

</pre>
</pre>
</div>
<p>&#160;</p>
<p>With a true DSL we can simplify even further to get right down to the bare minimum set of commands we need to execute what we want in our application.</p>
<h2>How to implement a DSL?</h2>
<p>There are a number of tools and techniques that can be used to create a DSL.&#160; I’ll hit on some of those a bit later on, but first we need to design the DSL itself.</p>
<p>Designing a DSL can be challenging, but I have found the best approach is to use a similar approach to what we used to <a href="http://simpleprogrammer.com/2011/03/16/getting-up-to-bat-designing-an-automation-framework/">design our automation framework</a>.</p>
<p>It is best to work backwards from the syntax that would make your BAT the easiest to write and the most clear.&#160; Once you have done that you can worry later about implementing the DSL to support the syntax you have come up with.</p>
<p>You should focus on creating a limited vocabulary for your DSL so that it will be easy for someone to learn and know what their options are.</p>
<p>The more restrictions we put into a DSL the easier that DSL becomes for doing a specific purpose.</p>
<p><strong>We want to give the user of a DSL no more options than required for what they want to do and no less.</strong></p>
<p>This isn’t always easy to do.&#160; It often requires some careful thought and refinement.</p>
<p>Your DSL should also use terminology and phrases that are familiar to the business domain of your application.&#160; By doing this you will make it so someone understanding your application will understand BATs written in that DSL.</p>
<p>I also always try to make a BAT DSL read as much as plain English as possible.</p>
<p>Once you have designed the DSL, you will need a way to implement it.&#160; </p>
<p>I’ve written about <a href="http://simpleprogrammer.com/2010/03/10/internal-dsl-becomes-external-dsl/">using ANTLR to create an external DSL</a>.&#160; Also I have written a review on a <a href="http://simpleprogrammer.com/2010/04/16/book-review-the-definitive-antlr-reference-building-domain-specific-languages/">book that I recommend for learning ANTLR</a>.</p>
<p>Microsoft also has a <a href="http://archive.msdn.microsoft.com/vsvmsdk">DSL SDK you can use in VS2010</a>, although I haven’t used it myself.</p>
<p>The basic idea behind implementing a DSL is that you have to take some sort of grammar you design for your DSL, parse it into a syntax tree, then use that tree to generate code that will actually perform the actions.</p>
<p>It is by no means a trivial task, but using a tool like ANTLR, makes it much simpler than trying to completely generate a parser and execution engine yourself.</p>
<h2>Why even bother?</h2>
<p>Creating a DSL for your BATs is completely optional, but there are some significant benefits to doing so.</p>
<p>The biggest one I have found is that you are much more likely to get business people to write BATs if you have a simple DSL they can use to create them.&#160; Once you get everyone using BATs to define behavior and requirements, communication becomes much more simple.</p>
<p>Another great thing about creating a DSL is that you can create a runner that can interpret the DSL BAT scripts which can be run on any machine.&#160; Typically, to run BATs created in Java or C#, you would need a C# or Java compiler and a test runner, etc.&#160; By creating a DSL and a stand alone executor, you can very easily allow anyone to run BATs with little to no setup.</p>
<p>Writing your BATs in a DSL will also make writing the BATs and understanding them much easier.&#160; A good DSL can get rid of all the little language and API nuances that don’t really add information to the specific domain you are working in.&#160; A good DSL strips information down to the minimum amount needed and is able to do so, because it assumes the context is your application’s business domain.</p>
<p>You will also find that you are better able to separate framework from tests when you have a DSL in place.&#160; One issue that many teams face when creating a BAT framework is that some people come along and write lower level code in the higher level BATs.&#160; This creates a problem because it is hard to force someone to use the higher level API when the framework and the BAT code are the same language.</p>
<h2>Wrapping it up</h2>
<p>So that completes my series on Getting up to BAT.</p>
<p>Hopefully you have learned enough to be able to implement your own BAT framework and get BATs running for your application.</p>
<p>I tried to cover most of the important steps here without getting too deep into the details.</p>
<p>If you have any questions or are interested in getting more in depth training or consulting on getting BATs setup for your environment, send me an email or leave a comment.</p>
<p>It can be a little difficult to get started and get a BAT framework up and running, but the rewards are well worth the effort!</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1329/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1329&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/05/14/getting-up-to-bat-building-a-true-dsl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/05/spinal_tap_but_it_goes_to_eleven_thumb.jpg" medium="image">
			<media:title type="html">spinal_tap_but_it_goes_to_eleven</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting up to BAT: Scaling Out</title>
		<link>http://simpleprogrammer.com/2011/05/05/getting-up-to-bat-scaling-out/</link>
		<comments>http://simpleprogrammer.com/2011/05/05/getting-up-to-bat-scaling-out/#comments</comments>
		<pubDate>Fri, 06 May 2011 04:03:25 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2011/05/05/getting-up-to-bat-scaling-out/</guid>
		<description><![CDATA[If you haven’t been following, it has been a while since my last post on this topic.&#160; I had a bit of distraction the last few weeks, but I am back and ready to go! When we last left off we had just gotten our BATs as part of the acceptance criteria for any new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1326&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you haven’t been following, it has been a while since <a href="http://simpleprogrammer.com/2011/04/12/getting-up-to-bat-adding-bats-to-your-acceptance-criteria/">my last post on this topic</a>.&#160; I had a <a href="http://simpleprogrammer.com/2011/04/25/the-most-complex-program-of-all-time/">bit of distraction</a> the last few weeks, but I am back and ready to go!</p>
<p>When we last left off we had just gotten our BATs as part of the acceptance criteria for any new backlogs that are worked on.&#160; This puts us at a point where we could really say that we have successfully implemented BAT testing.</p>
<p>You don’t want to get too comfortable just yet though, because the next hurdle you will most likely face will be the problem of not having enough time to execute all your tests.</p>
<h2>You want to think about this ahead of time</h2>
<p>Nothing worse than getting everything going and then not being able to execute the entire test suite, because you didn’t plan ahead.</p>
<p>You don’t want to get to the point where confidence in your BAT suite it lost because you are not able to get all the tests executed in a reasonable amount of time.</p>
<p><strong>The more frequently your tests are run the more value they have.</strong></p>
<p>By reducing cycle time from the time a breaking change is made in the system and the time it is discovered, you greatly reduce the risk it imposes on your software and you decrease the scope of the code changes in which it could have occurred.</p>
<p>To put it simply, the faster you can find out you broke something, the more likely you can fix it before it does damage, and the more likely you will be to know what thing you did caused the breakage.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/05/clarkson_face.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="clarkson_face" border="0" alt="clarkson_face" src="http://complextosimple.files.wordpress.com/2011/05/clarkson_face_thumb.jpg?w=485&#038;h=361" width="485" height="361" /></a></p>
<h2>How can we reduce cycle time?</h2>
<p>There are a few different strategies we can employ and we can mix and match some of these strategies.</p>
<p><strong>Straight forward parallelization</strong></p>
<p>The best and most effective thing you can do is to take a given test run, split up the execution of those tests on multiple machines and execute them in parallel.</p>
<p>This approach is going to give you the best bang for your buck.&#160; You should really try to get some amount of parallelization going before attempting any other solution, since it is going to make a huge impact on the total execution time for your tests without making any sacrifices.</p>
<p>There are even many ways you can mix and match to do parallelization:</p>
<ul>
<li>Use multiple physical machines</li>
<li>Run many virtual machines on a single host</li>
<li>Put an executor program on every team member’s machines that will execute tests when that machine is idle or put into test execution mode (perhaps at night)</li>
<li>Use a cloud based computing platform to execute your tests</li>
<li>Run multiple browser instances on a single machine</li>
</ul>
<p><strong>Data preloading</strong></p>
<p>With this approach, you would preload some of the test data that your tests might generate by manually clicking through screens.</p>
<p>This is fairly hard to explain, so let me give you an example:</p>
<p>Suppose you had a set of tests that all involved creating customers, but each customer you create in the system takes about 3 minutes to create by clicking through the screens to get them into the system.</p>
<p>We don’t need to have 500 tests all executing the same exact logic in the system 500 times for 3 minutes just to generate all the customer data that will be used in the tests.</p>
<p>Instead, we can leave a few tests that are exercising the customer creation functionality, and we can execute a SQL script to push all the other customer data into the test database for the other tests to use.</p>
<p>Using this technique we might be able to reduce our total execution time by 3 minutes * each test, or about 25 hours for 500 tests.</p>
<p>This can be a huge savings in time, and it doesn’t come at that high of a cost.&#160; The sanctity of our tests is slightly compromised, but we are taking a calculated risk here knowing that we already have covered the area of execution which we are preloading data for.</p>
<p>Consider this technique when you notice certain things in the system taking a very long time to do.</p>
<p><strong>Test runs by area</strong></p>
<p>With this technique, we can reduce the total execution time in a given period by splitting up test areas and running them either at different times or in response to changes in certain areas.</p>
<p>You have to be very careful with this approach, because if you don’t do it correctly, you can start to erode some of the safety your BAT tests are providing you.</p>
<p>I would only do something like this as a last resort, because it is so easy to virtualize today, and hardware is so cheap.</p>
<p>I’d much rather run too many tests than too few.</p>
<p><strong>Test randomization</strong></p>
<p>With test randomization, we are going to take our total desired execution time, and divide it by the average time for running a test.&#160; We then can use that number of tests to run to randomize the execution of our tests each time we run them and only run the number or tests that will fit in the desired execution time.</p>
<p>This choice is also a compromise that I typically don’t like to take.</p>
<p>It can be very useful though, combined with other techniques when you still don’t have enough time to execute your entire test suite.</p>
<p>The basic idea here is that you are going to randomly run tests each time to fill up the time you have to run tests.</p>
<p><strong>Test reduction</strong></p>
<p>This one seems fairly obvious, but can be very helpful.</p>
<p>Often I will see teams starting out with automation, trying to write way too many BAT tests for a given feature.&#160; Sure, with automated tests it is possible for run a test for every single possible combination of values in your 5 drop downs, but will it really benefit you?</p>
<p>In many cases you have to think about what you are trying to protect against with your BATs.&#160; Sometimes running every combination of data selection choices is going to be important, but other times you are only going to need to write tests to test a few of the happy path scenarios.</p>
<p>It is important to find a balance between test coverage and test volume and not just for execution time.&#160; There is a logistical overhead to having a large volume of mostly redundant tests.</p>
<p>So even though this technique might seem dangerous and counter-productive, I will almost always employ it to some degree.</p>
<h2>Common pitfalls</h2>
<p>Here are some of the things you might want to watch out for as you are scaling out and streamlining your execution of BATs:</p>
<ul>
<li><strong>Parallelization issues.&#160; </strong>If you are using shared state, you can run into big trouble when your tests are executing in parallel.&#160; There are many manifestations of this.&#160; You could have issues at the database level or at the local machine memory level.&#160; The best way to avoid this kind of problem is to use separate virtual machines for each test execution, and not reuse data setup between test cases.</li>
<li><strong>Ineffective error reporting.&#160; </strong>If you run a huge volume of tests in parallel, you better have a good way to sort through the results.&#160; It is much harder to figure out why things failed when they are run across multiple machines.</li>
<li><strong>Test order dependencies.&#160; </strong>Make sure tests don’t rely on being run in a certain order or you will have lots of pain when you disrupt that order.</li>
<li><strong>Environment setup.&#160; </strong>Make sure all your test execution environments are exactly the same unless you are specifically testing different environments for execution.&#160; You don’t want tests failing on one machine but passing on another.</li>
</ul>
<p><strong>As always, you can subscribe to this </strong><a href="http://feeds.feedburner.com/MakingTheComplexSimple"><strong>RSS feed</strong></a><strong> to follow my posts on Making the Complex Simple.&#160; Feel free to check out </strong><a href="http://elegantcode.com/"><strong>ElegantCode.com</strong></a><strong> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter </strong><a href="http://twitter.com/jsonmez"><strong>here</strong></a><strong>.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1326/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1326/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1326/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1326&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/05/05/getting-up-to-bat-scaling-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/05/clarkson_face_thumb.jpg" medium="image">
			<media:title type="html">clarkson_face</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting up to BAT: Adding BATs to Your Acceptance Criteria</title>
		<link>http://simpleprogrammer.com/2011/04/12/getting-up-to-bat-adding-bats-to-your-acceptance-criteria/</link>
		<comments>http://simpleprogrammer.com/2011/04/12/getting-up-to-bat-adding-bats-to-your-acceptance-criteria/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 05:00:05 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Process Improvement]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1308</guid>
		<description><![CDATA[So now that we have built our automation framework, and got our smoke tests running as part of the build, we now need to make sure new BATs are being created for new backlogs. This is definitely one of the more challenging tasks you will face, and perhaps the most critical. All of your efforts [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1308&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So now that we have <a href="http://simpleprogrammer.com/2011/03/16/getting-up-to-bat-designing-an-automation-framework/">built our automation framework</a>, and got our <a href="http://simpleprogrammer.com/2011/04/05/getting-up-to-bat-adding-smoke-tests-to-your-build/">smoke tests running as part of the build</a>, we now need to make sure new BATs are being created for new backlogs.</p>
<p>This is definitely one of the more challenging tasks you will face, and perhaps the most critical.</p>
<p>All of your efforts will be in vain if you can’t get to the point of creating new BATs for new backlogs that are finished, because if you don’t you’ll still be doing manual testing, and you’ll be playing catch-up all the time.</p>
<h2>Start off small</h2>
<p>The goal here is to eventually get to the point where every single backlog requires BATs to be written and passing in order for that backlog to be called “done.”</p>
<p>If you try to drop this lofty goal onto a team in one iteration, you are likely to get beaten and slapped with much vigor.</p>
<p>Instead, start with a simple goal of requiring that at least one backlog have BATs for all of the functionality of that backlog.  Start with this small goal, but enforce it with rigor.</p>
<p>By starting out small like this, you will get the team accustomed to the idea of building automated tests at the same time as building the functionality and you will give them a chance to have a small success without sacrificing much velocity.</p>
<p>The goal at this point should be to get people excited about writing BATs along with the backlog.</p>
<h2>It’s actually quite fun</h2>
<p>I have found that developers tend to really enjoy writing automated tests.  Make sure you let everyone who wants to share in the fun, not just QA and not just developers.</p>
<p>It is really very exciting to see the “magic” of an automated test clicking through buttons on your web page and doing all kinds of things that seemed so tedious before.</p>
<p>I have found that this is so much fun, that you might have the problem of developers not wanting to work on the real backlog, but rather to write the automated tests for it.</p>
<p>This is good, you really want to foster this attitude, it will greatly help when you finally…</p>
<h2>Drop the bomb!</h2>
<p>What bomb?  The bomb that says on it:</p>
<blockquote><p><strong>All backlogs will require BATs as acceptance criteria.  It’s not done unless it has automated tests that prove its functionality.</strong></p></blockquote>
<p>You should be getting to this point within 3 to 4 iterations on average.  Don’t go too fast to get here, but don’t go too slowly either.</p>
<p>I know this seems like an impossible task, but it really isn’t.  I’ve been here before and had much success with it on several different teams.  The key is making sure everyone is comfortable with writing automated tests and understands the value.</p>
<p>Whatever you do though, once you draw this line in the sand, <strong>Do not back down! </strong>I mean it.</p>
<p>You might start getting death threats.  People might directly laugh in your face all the while spitting skittle colored loogies in your coffee, daring you to “taste the rainbow,” but you have to hold your ground.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/04/skittlesny6.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="skittlesny6" src="http://complextosimple.files.wordpress.com/2011/04/skittlesny6_thumb.jpg?w=473&#038;h=396" border="0" alt="skittlesny6" width="473" height="396" /></a></p>
<p>It will be worth it in the long run, because you will have built an awesome safety net for proving the functionality of your software over time.</p>
<h2>It’s not all rainbows and butterflies</h2>
<p>You are going to sometimes run into scenarios where automation will be too high of a price for a particular backlog.</p>
<p>This will especially happen in cases where you have some kind of process that spans multiple domains or software systems.</p>
<p>When you run into those situations, give it a solid effort to at least automate as much as possible, but don’t die on the hill and kill the whole automation project.  We have to be pragmatic or risk having our credibility called into question.</p>
<p>Don’t expect everyone to embrace writing BATs overnight, or to even be good at it.  When you first introduce this to the team, you are going to have a learning curve and your automation framework is still going to have some pretty big holes in it.</p>
<p>But, that is OK.  Over time you will build out that framework and produce some fierce battled scarred veterans able to automate web pages while scowling at you from afar, just don&#8217;t lose hope and keep beating that drum!</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple. Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week. Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1308/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1308&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/04/12/getting-up-to-bat-adding-bats-to-your-acceptance-criteria/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/04/skittlesny6_thumb.jpg" medium="image">
			<media:title type="html">skittlesny6</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting up to BAT: Adding Smoke Tests to Your Build</title>
		<link>http://simpleprogrammer.com/2011/04/05/getting-up-to-bat-adding-smoke-tests-to-your-build/</link>
		<comments>http://simpleprogrammer.com/2011/04/05/getting-up-to-bat-adding-smoke-tests-to-your-build/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 15:48:16 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1295</guid>
		<description><![CDATA[Once you’ve built some smoke tests with your shiny new automation framework, you are going to want to get those smoke tests up and running as soon as possible… But!  You might want to consider holding off for a second and reading this post! It is worth taking a bit of time and thinking a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1295&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Once you’ve built some smoke tests with your shiny new automation framework, you are going to want to get those smoke tests up and running as soon as possible…</p>
<p>But!  You might want to consider holding off for a second and reading this post!</p>
<p>It is worth taking a bit of time and thinking a bit about the strategy and psychology of adding the smoke tests to your regular build process.</p>
<p>There are several things we are going to want to discuss and think about before adding automated tests to a build.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/04/build-a-site2.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="build a site2" src="http://complextosimple.files.wordpress.com/2011/04/build-a-site2_thumb.jpg?w=497&#038;h=335" border="0" alt="build a site2" width="497" height="335" /></a></p>
<h2>Why are we adding the smoke tests to the build?</h2>
<p>I think it is always important that before we do something we ask ourselves why we are doing it.  Doing things, because someone said it is good, or because it seems right is not a very good reason.</p>
<p>The primary benefit we are going to get by adding smoke tests to the build now instead of waiting for a larger portion of tests to be written is that we are going to be able to immediately tell if a basic functionality of the system is broken instead of finding out after we have deployed the build to different environments and used it.</p>
<p>We want to be able to get this value as soon as possible.  We don’t want to have to wait until we have a huge amount of tests, because even a few tests will give us some value in this area.</p>
<p>The other reason we are adding the tests to the build is so that we can notify developers when a test fails, so that they know to fix whatever was broken.  By having the smoke tests run as part of the build, we are able to reduce the amount of time before a break is introduced and the break is discovered.</p>
<p>This concept of reducing the delta between introduction and discovery is very important, because it makes it much easier to identify what caused a break.</p>
<p>Perhaps a distant 3rd reason to add the smoke tests at this stage, is to prove out our framework and technologies.  Better to start small with a small number of tests and get everything working.</p>
<p>With those ideas in mind, we can move onto some of the more important considerations.</p>
<h2>Don’t ever add failing tests to the build</h2>
<p>When you add your smoke test suite to the automated build, all of the tests should pass!</p>
<p>I will say it again, because it is really important and ignoring this advice may doom your entire BAT project.</p>
<blockquote><p><strong>Do not ever add failing tests to the build!</strong></p></blockquote>
<p>It seems like an innocent enough thing, but it causes great harm, because it is very much like the boy who cried wolf.  Consider what happens when we introduce our new BAT system and we add our smoke tests to the build, but we have 3 failing tests.</p>
<p>First thing that will happen is that our tests will run during the next build and 3 will fail.  This should cause a build failure notification of some sort to go to the team, at which time you will be in the uncomfortable position of saying something to the effect of “ignore that fail, those are real defects, but they are known issues.”</p>
<p>Next, let’s assume a developer checks in some bad code and it causes a 4th test to fail.</p>
<p>Do you think most people will notice this 4th failing test?</p>
<p>Even if they do, do you think they will just assume it is another known issue?</p>
<p>Worse yet, they may think your BATs are meaningless and just fail randomly.</p>
<p>Do you see where I am going with this?  We want to start off with the correct expectations and we want test failures to be meaningful.  To ALWAYS be meaningful.  The second you have test failures that are not meaningful, you lose credibility for any future meaningful failures.</p>
<p>This is such a critical psychological battle with build systems and automated tests that I have often implemented a policy where no one is allowed to work on anything else but fixing the build or test failure when a build fails.  When you have 20 developers either sitting idle or working on one issue for 2 hours, it sends a pretty clear message that we take build failures seriously.</p>
<p>Make sure your tests never undermine this message.</p>
<h2>What do I do with failing tests then?</h2>
<p>If they are real defects, put them in your defect tracking system or create backlogs for them and make sure the tests are disabled until those defects are fixed.</p>
<p>Your automated tests should be acting as regression tests for things that are already working.  It is absurd to think that it is even close to cost effective to write automated tests to actually functionally test new features or code!</p>
<p>It is the process of writing the automated test that should uncover defects.  Running of automated tests should uncover new defects where functionality has regressed from working to not working.</p>
<h2>Other considerations</h2>
<p>Here are a list of some other considerations you will want to think about before embarking on this journey.</p>
<ul>
<li><strong>How will you actually run the tests?</strong> (Will you use the build script to kick it off, some 3rd party plugin, etc)</li>
<li><strong>Where will you run the tests?</strong> (Will you use the build server itself, or another machine.  You probably don’t need to worry about scaling out to multiple machines right now, but you should at least keep it in the back of your mind.)</li>
<li><strong>How long will it take to run the smoke tests?</strong> (Fast is better, because feedback cycle is reduced.  If you have a really long test suite, you might want to pare down the smoke tests and run some with every build, and all of them every night for now.)</li>
<li><strong>Will developers be able to run the tests locally?</strong> (Make sure you consider how to do this before putting the tests into the build.  Nothing more frustrating than being measured against a bar you can’t yourself see.)</li>
<li><strong>How will you notify and report results from the test failures?</strong> (We don’t care about passes, only failures, but you need a good way to report the result that prompts action.)</li>
<li><strong>What is the policy for test failures? </strong> (Make sure there is some agreement on what kind of action will be taken when tests fail.  A great place to start, if you can get management to buy in on it, is all work stops until all tests pass.  Extreme, but extremely effective.)</li>
<li><strong>How will you prevent false fails and identify them? </strong>(Don’t get stuck with egg on your face.  If your framework fails and the problem is not a real defect, you need to be able to quickly identify it and fix the framework problem.  There are a few strategies for doing this, but that is for another post.)</li>
<li><strong>How do new tests get added and commissioned?</strong> (You are going to be constantly growing your test suite, so you will need a good method for adding tests to the smoke test suite.)</li>
</ul>
<p>Remember, you only get one chance at a first impression!</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.  Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1295/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1295&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/04/05/getting-up-to-bat-adding-smoke-tests-to-your-build/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/04/build-a-site2_thumb.jpg" medium="image">
			<media:title type="html">build a site2</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting up to BAT: Creating Your First Smoke Tests</title>
		<link>http://simpleprogrammer.com/2011/03/28/getting-up-to-bat-creating-your-first-smoke-tests/</link>
		<comments>http://simpleprogrammer.com/2011/03/28/getting-up-to-bat-creating-your-first-smoke-tests/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 23:15:11 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2011/03/28/getting-up-to-bat-creating-your-first-smoke-tests/</guid>
		<description><![CDATA[If you have been following my posts so far on Becoming Bat Man, you should already have hired an automation lead, figured out what browser driver you are going to use and come up with a design plan for your automation framework. Now you are probably faced with the difficult decision of… Where to begin [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1292&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have been following my posts so far on <a href="http://simpleprogrammer.com/2011/02/05/back-to-basics-becoming-bat-man/">Becoming Bat Man</a>, you should already have <a href="http://simpleprogrammer.com/2011/02/23/getting-up-to-bat-hiring-an-automation-lead/">hired an automation lead</a>, <a href="http://simpleprogrammer.com/2011/03/06/getting-up-to-bat-picking-a-browser-automation-tool/">figured out what browser driver you are going to use</a> and come up with a <a href="http://simpleprogrammer.com/2011/03/16/getting-up-to-bat-designing-an-automation-framework/">design plan for your automation framework</a>.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/03/smoking_computer.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="smoking_computer" border="0" alt="smoking_computer" src="http://complextosimple.files.wordpress.com/2011/03/smoking_computer_thumb.jpg?w=465&#038;h=471" width="465" height="471" /></a></p>
<p>Now you are probably faced with the difficult decision of…</p>
<h2>Where to begin with your tests</h2>
<p>I don’t suggest writing your automation framework first and then writing tests to use it.&#160; If you go this route you’ll have two problems</p>
<ol>
<li>It will be a long time and large investment before you see any fruits from your automation effort. </li>
<li>Your framework will likely be designed incorrectly or not test-writer friendly.&#160; (Which is basically the same as wrong.) </li>
</ol>
<p><strong>What you really want to do is to write some basic tests that let the development of those tests drive the development of your framework.</strong></p>
<p>The best tests to drive your framework are some basic “smoke tests.”&#160; If you are not familiar with the term “smoke test,” it basically means some tests that make sure the application you are testing is at least somewhat working and not completely broken.&#160; </p>
<p>There are a few different opinions of what exactly constitutes a smoke test, but in general, if you have any tests that you regularly run on a new build to make sure it is at least OK, those would be the tests we are interested in here.</p>
<p>You are going to want to start by taking the easiest and most simple tests you have and writing them in a concise syntax that you use to drive the development of your framework.</p>
<p>It is very important at this stage to not worry about what you think might be possible or how it would be implemented in the framework, but to instead focus and making the tests as terse and explanative as possible.</p>
<p>The basic idea is that you will write the test out in the syntax you would like to be able to use, then implement the framework features required to make that test pass.&#160; This whole process is very similar to doing Test Driven Development.</p>
<h2></h2>
<h2></h2>
<h2>An example case</h2>
<p>The easiest way to demonstrate this is with an example.</p>
<p>Let’s say you have a smoke test like the following:</p>
<p><em>Create a new account, pick an on-sale item, add it to your cart and check out using PayPal.&#160; Verify that we hit the order success page.</em></p>
<p>We might write a test for this that looks something like:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:835fd59d-5f61-4af6-ba64-04228d582e22" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp; pad-line-numbers: true;">
Workflow.Users.CreateNewUser();
Pages.Login.LoginWithLastCreatedUser();
Pages.SaleItems.AddAnyToCart();
Workflow.Cart.CheckoutUsingPayPal();
Assert.True(Pages.Checkout.SuccessPage.IsAt());


</pre>
</pre>
</div>
<p>What I just wrote above is astonishingly simple.&#160; You are likely saying to yourself something along the lines of “What if… blah.”</p>
<p>Forget it!&#160; We’ll handle “what if” later.&#160; Right now we are going to write the tests as terse as possible and not handle any other conditions.</p>
<p>What I wrote above is the style that I like to write the tests in, which is highly subject to opinion, but the content of what I wrote is not as subjective.</p>
<p>There are a few important points to note:</p>
<ul>
<li>I used methods like <em>CreateNewUser</em>, <em>LoginWithLasteCreatedUser</em> and <em>CheckoutUsingPayPal</em> that do a huge amount of work and have no parameters.&#160; Why?&#160; Because for the purpose of this test, (and you’ll find for most of your tests), we don’t care about what the first name or last name or address of the user is, we don’t care how we get them logged in, and we only care that they checkout using PayPal, not what account is used, etc. </li>
<li>I didn’t declare any variables.&#160; Tests should be simple.&#160; Let the framework remember the state. </li>
<li>I over-simplified.&#160; This is fine, you are working inside of a very specific domain.&#160; Let your test framework methods do one large thing.&#160; Don’t worry about oversimplifying for now. </li>
<li>I asserted something at the end.&#160; All tests need to assert something.&#160; If you can’t figure out what to assert, work on redesigning the test before automating it. </li>
<li>I didn’t pass parameters.&#160; Avoid this also.&#160; <strong>This goes along with the first point, but is so important that I feel it is OK to state it twice.</strong>&#160; If you don’t care about variation, eliminate it.&#160; You will constantly need to find places where a manual tester would have to enter specific information, but an automated test won’t care what that information is. </li>
<li>All my methods are static.&#160; While this would be bad in normal production code, for a test API it is the easiest for test writers to use.&#160; No variable declarations, no “newing” up objects, no constructors, etc. </li>
<li>It’s written in “business language.” As close to the language an end user or business person would use to describe the test.</li>
</ul>
<p>So, this test is definitely doing a huge amount of stuff in a few lines of code, and because of this your inclination would be to say that the API level is too high. Don’t!</p>
<p>Instead, make the API level as high as you possibly can, until further tests you try to implement prove to you that it must be broken down further.</p>
<p>By working this way, you ensure a reduction in the total lines code and complexity of your tests by as much as possible.</p>
<p>You would NEVER work like this with normal code, but for automated tests this is essential.&#160; The main reason is because you will be calling the same methods perhaps 1000s of times, where in normal code you usually only reuse a method in a few places. </p>
<h2>Next steps</h2>
<p>For my example above, the next step would be going through and implementing all the framework methods required in order to make that test runnable.&#160; You will end up utilizing the general design you came up with for your automation framework to do this.</p>
<p>Then you will simply move on to the next test and repeat.&#160; Each time you should have less and less effort required, as more of the basic functionality of your automation framework is implemented.</p>
<p>Automating your smoke tests should ensure that you get a fairly even distribution of the framework code written as the smoke tests should cover many different areas of your software.</p>
<p>But, don’t start adding these smoke tests to your build yet.&#160; We’ll cover that in the next step.&#160; Adding them to the build prematurely can cause the confidence in these tests to be forever diminished!&#160; We don’t want to do that!</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1292/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1292/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1292/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1292&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/03/28/getting-up-to-bat-creating-your-first-smoke-tests/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/03/smoking_computer_thumb.jpg" medium="image">
			<media:title type="html">smoking_computer</media:title>
		</media:content>
	</item>
		<item>
		<title>Guest Post: The Cross-Browser Compatibility Myth</title>
		<link>http://simpleprogrammer.com/2011/03/22/guest-post-the-cross-browser-compatibility-myth/</link>
		<comments>http://simpleprogrammer.com/2011/03/22/guest-post-the-cross-browser-compatibility-myth/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 02:57:59 +0000</pubDate>
		<dc:creator>hsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Guest Post]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=1277</guid>
		<description><![CDATA[This post is a special guest post from my wife, Heather Sonmez, who is an expert on the subject of blackbox automated tests and designing frameworks for them.  She has designed successful automation frameworks for several companies.  She deals with software automation and framework design issues on a daily basis, so I thought she might [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1277&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="color:#00b050;font-size:small;"><span style="color:#00b050;font-size:small;"> </span></span><span style="color:#00b050;font-size:small;"><span style="color:#00b050;font-size:small;"><span style="color:#00b050;font-size:small;"><span style="color:#00b050;font-size:small;"> </span></span></span></span></p>
<div><em>This post is a special guest post from my wife, Heather Sonmez, who is an expert on the subject of blackbox automated tests and designing frameworks for them.  She has designed successful automation frameworks for several companies.  She deals with software automation and framework design issues on a daily basis, so I thought she might be able to offer some good insight on the topic.</em></div>
<div>
<p></div>
<div>
<p>John asked me to write a post based on my experience with writing automated tests.  I’ve been working as a QA Automation Engineer for the past three and a half years. During this time I have had the opportunity to work with Ruby/Watir, C#/Watin, and Java/Selenium RC. In thinking on a topic, I decided that there’s no time like the present to talk about what I’m presently facing, and would like to share some insight straight from the trench I currently find myself in today:</p>
</div>
<h2>Automation tools that claim to support multiple browsers are LYING</h2>
<p>Currently I am in the process of getting 400 automated tests that run in Firefox to run in Internet Explorer and Chrome. While the tests are using Selenium RC, a tool that claims to work on all three browser platforms, in actuality, many tests are failing and not for good reasons (bugs).</p>
<p>Here’s the rundown on what these overly-ambitious tools aren’t telling you:</p>
<ul>
<li>Xpath in Browser A isn’t always supported in Browser B</li>
<li>The Dom in Browser A may vary from the Dom in Browser B</li>
<li>Browser B may have built-in security settings that interfere with testing</li>
<li>Bugs in the automation tool itself may cause issues in specific browsers</li>
</ul>
<div><span style="font-size:20px;font-weight:bold;"><strong>The XPath Issue</strong></span></div>
<p>When it comes to XPath, I fully expected that any given expression was either valid or invalid. But it didn’t take more than one test run in Internet Explorer to suddenly find myself with tests that claimed certain elements didn&#8217;t exist. While Firefox accepted and successfully returned my element using the provided expression, IE claimed the expression itself was invalid. In this particular instance I discovered an issue with Selenium stripping off the end of my xpath statement, thus making it invalid.</p>
<p>But ultimately, whether it&#8217;s the browser or the tool doesn&#8217;t matter because the same expression is not working unequivocably in both browsers.</p>
<p><strong> </strong><strong> </strong></p>
<h2><strong>The Dom Issue</strong></h2>
<p>The next problem I immediately came across was the problem of Dom differences between browsers. In this particular case I had an element that occurred one time in Firefox but twice in IE. My test, expecting one instance of the element, failed. While I can’t tell you why this discrepancy exists (currently under investigation by some client-side engineers), I have a fair degree of confidence in saying this won’t be the last time I come across this issue.</p>
<p>In the quest to support many different browsers, it only follows that one is going to come across conditional browser logic, especially if a company is striving to support multiple browser versions (IE 6, 7, 8, 9). If a developer has to occasionally write browser-specific condition statements, it makes sense that we&#8217;d have to do the same to test specific browsers.</p>
<p><strong> </strong><strong> </strong></p>
<h2><strong>The Security Issue</strong></h2>
<p>If it seems that I’m picking on IE, it’s only because I can’t get very far in running our tests in Chrome. Chrome has special security settings that cause a Selenium exception if your test changes domains mid-run. This can easily be solved by passing a parameter to Chrome which will disable this security feature when the test runs, the trick is figuring out when/where/how to pass that parameter.</p>
<p><strong> </strong><strong> </strong></p>
<h2><strong>The Bug in the Tool Issue</strong></h2>
<p>Finally, the last obstacle I’ve come across in multi-browser testing: the tool itself. Any tool, regardless of how fabulous it is, is going to have bugs. Selenium RC has an issue where its select method (responsible for selecting a value in a dropdown menu) doesn’t trigger affiliated event handlers- in Internet Explorer. To work around this, one can manually call the event handler using Selenium’s runscript() but you will lose some degree of testing confidence in doing so (how do you know the event is really firing in response to a particular user action if you’re manually forcing it in automation?)</p>
<p>Another issue exists around multiple browser windows; if you need more than one open for your test, Selenium is unable to select the second window you open- another outstanding IE issue that has not been resolved.</p>
<p><strong> </strong><strong> </strong></p>
<h2><strong>Summary</strong></h2>
<p>In all fairness, some of these issues have more to do with the browsers themselves than with the automation tool. However, that makes it even more important to realize that when an automation tool says it supports multiple browsers, it’s not without some creativity, troubleshooting, legwork, and maintenance.</p>
<p>Knowing these kinds of issues exist is important in order to decide if and how much browser compatibility testing you want to automate. It&#8217;s definitely something to realize before deciding on a tool just because the tool claims to support other browsers.</p>
<p><strong>Just as there is no silver bullet for writing a web application that works in every browser imaginable, there is no silver bullet for automation either.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1277/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1277/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1277/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1277&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/03/22/guest-post-the-cross-browser-compatibility-myth/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ec419ec8af10304b5129e246c0807c35?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">hsonmez</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Up to BAT: Designing an Automation Framework</title>
		<link>http://simpleprogrammer.com/2011/03/16/getting-up-to-bat-designing-an-automation-framework/</link>
		<comments>http://simpleprogrammer.com/2011/03/16/getting-up-to-bat-designing-an-automation-framework/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 00:01:36 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Functional]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2011/03/16/getting-up-to-bat-designing-an-automation-framework/</guid>
		<description><![CDATA[Now that you’ve gotten an automation lead and decided on the browser automation tool you are going to use, the next step is to design an actual automation framework. This is one of the most critical components of the overall success of your automation strategy, so you will want to make sure you invest properly [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1275&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now that you’ve gotten an automation lead and decided on the browser automation tool you are going to use, the next step is to design an actual automation framework.</p>
<p>This is one of the most critical components of the overall success of your automation strategy, so you will want to make sure you invest properly in this area.</p>
<p>I have seen a large number of automation projects go forth, but each time the critical component determining their success or failure was having a good automation framework.</p>
<p>Solid design and excellent technical resources are absolutely critical to success in this area!</p>
<h2>What is an automation framework?</h2>
<p>An automation framework is essentially an API that all of your BATs (Blackbox Automated Tests) are written against.</p>
<p>This API can be as simple as the API that is exposed by your browser automation tool (WatiN, Selenium, etc.), but I would highly recommend building your own layer on top of the browser automation tool’s API that will act as a DSL (Domain Specific Language) for automating your application.</p>
<p>Let me break this down a bit further by using an example.</p>
<p>Think about the task of making coffee.</p>
<p>There are several “API” levels we can interact with.</p>
<ol>
<li>We can go with a very low level API where we take whole coffee beans and grind them down.&#160; Then we take some water, get it hot.&#160; We take our filter put the ground beans in it, put it over a cup and pour the water into the filter.</li>
<li>We can go with a higher level API where we use a traditional coffee maker.&#160; In this case we load the coffee maker with a filter, ground coffee beans and water and push a “brew” button.&#160; We could also set it to start at a certain time.</li>
<li>We can go with a very high level API where we use a <a href="http://www.amazon.com/gp/product/B000AQSMPO/ref=as_li_ss_tl?ie=UTF8&amp;tag=makithecompsi-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B000AQSMPO">Keurig</a> machine or similar device.&#160; In this case we only make sure the machine has water in it, and we just insert a little pod and press brew.&#160; We can make different kinds of coffee, cider or hot cocoa just by changing what pod we use.</li>
</ol>
<p><a href="http://complextosimple.files.wordpress.com/2011/03/unnamed.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="unnamed" border="0" alt="unnamed" src="http://complextosimple.files.wordpress.com/2011/03/unnamed_thumb.jpg?w=220&#038;h=220" width="220" height="220" /></a></p>
<p>Using the API provided by the browser driver is like making the coffee by hand.&#160; It’s going to take a large amount of effort each time you do it.</p>
<p>We want our automation framework to be more like the Keurig machine.&#160; We want to be able to compartmentalize our tests in little pods that are small and don’t require many hooks into the automation framework.</p>
<p>To rehash this one more time, basically our automation framework will be a framework we build on top of the browser driver framework, which is designed to make it easy to write tests which automate our application.</p>
<h2>What makes a good automation framework design?</h2>
<p><strong>The true measure of an automation framework is the size of the tests that are written against them. The less lines of code in each test, the better the automation framework captures the domain of the application being automated.</strong></p>
<p>In my <a href="http://simpleprogrammer.com/2010/01/05/automated-ui-testing-framework-a-real-example/">earlier post about an example of an automation framework</a>, I talked a bit about the strategy I used in a real implementation of an automation framework.</p>
<p>Here is a diagram showing the different layers.&#160; You can see the framework layer is in green here.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/03/automated_testing_framework-2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="automated_testing_framework-2" border="0" alt="automated_testing_framework-2" src="http://complextosimple.files.wordpress.com/2011/03/automated_testing_framework-2_thumb.png?w=482&#038;h=577" width="482" height="577" /></a></p>
<p>You can also see in this diagram that on the right hand side, I have screens, workflows and navigation.</p>
<p>This is one of the common design patterns you can use to build your automation framework, since it closely models that of most web applications.</p>
<p>A good way to design your framework is to use a pattern like this and create classes for each page in your application, create classes which might represent workflows in your application, and create some classes for navigating around the application.</p>
<p>The basic idea you are shooting for with your automation framework is to make it so the tests do not have to know anything about the browser.&#160; Only your automation framework itself should be dealing with the DOM and HTML and CSS.&#160; Your tests should be dealing with concepts which any user would be familiar with.&#160; That is why I commonly use pages and workflows.</p>
<p>Let me give you an example.</p>
<p>Let’s say we ignored the advice of creating an automation framework and decided to program our tests directly against the browser driver layer.&#160; In this case, let’s say that we want to automate a login page.&#160; Our test might look something like this pseudo-code.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:af0bdb44-e0ca-4c0b-94d6-200830b1ed71" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp; pad-line-numbers: true;">
browser.goto(&quot;http://mywebsite/login.aspx&quot;);
Element userName = browser.getElementById(&quot;login_userName&quot;);
userNameTextField.Type(&quot;Joe&quot;);

Element userPassword = browser.getElementById(&quot;login_userPassword&quot;);
userPassword.TextField.Type(&quot;mypassword&quot;);

Element loginButton = browser.
    getElementByXPath(&quot;//button[class=&quot;loginButton&quot;]&quot;);
loginButton.Click();
</pre>
</pre>
</div>
<p>&#160;</p>
<p>This is not very readable.&#160; It is not something an average tester will be able to pick up and start writing, and it is extremely fragile.&#160; If you have 500 tests like this and the id changes for one of the elements on the page, many tests will break.</p>
<p>Now, contrast it to this pseudo-code:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:a727af81-9910-4280-bab2-a5da7a354e0d" class="wlWriterEditableSmartContent">
<pre>
<pre class="brush: csharp;">
Pages.Login.Goto();
Pages.Login.LoginWithDefaultUser();
</pre>
</pre>
</div>
<p>&#160;</p>
<p>Where did all the code go?&#160; You don’t need it!&#160; Actually it went into the framework, where it can be reused.&#160; Now your test code is simple, can be understood by just about anyone, and won’t break with changes to the UI.&#160; (You will just have to change the framework method instead of 500 tests.)</p>
<p>If you want some more detailed examples take a look at my Boise Code Camp slides on the subject <a href="http://www.slideshare.net/jsonmez/internal-ds-ls-for-automated-functional-testing">here</a>.</p>
<p>Let me offer up some general guidelines for creating a good design for an automation framework.</p>
<ol>
<li>NEVER require the tests to declare variables.</li>
<li>NEVER require the tests to use the <em>new</em> keyword or create new objects.</li>
<li>NEVER require the tests to manage state on their own.</li>
<li>ALWAYS reduce the number of parameters for API calls when possible.</li>
<li>ALWAYS use default values instead of requiring a parameter when possible.</li>
<li>PREFER to make the API easier to use over making the internals of the API less complex.</li>
<li>PREFER using enumerations and constants to requiring the test to pass in primitive types.&#160; (Make the input bounded when possible.)</li>
<li>NEVER expose the browser or DOM to the tests or let them manipulate it directly.</li>
</ol>
<p>You can see that these guidelines will almost force your API to be entirely static methods!&#160; Don’t freak out.&#160; It is perfectly fine.&#160; There is nothing wrong with using static methods in this case.</p>
<p>Stop… take a breath, think about why you think static methods are bad, because <a href="http://simpleprogrammer.com/2010/01/29/static-methods-will-shock-you/">I probably agree with you.</a></p>
<p>But, in this case we are HIGHLY valuing making the tests simple and easy to write over anything else, and because of this emphasis, static methods are going to be the way to go.</p>
<h2>Some advice on getting started</h2>
<p>Start with the tests in plain human English.</p>
<p>Take those tests and make them into code preserving as much English as possible.&#160; Then work down from there implementing the methods needed to make those tests work.&#160; Only add things as you need them.&#160; Do not overdesign!</p>
<p>In my example above, we might have started with something like this:</p>
<p>1. Goto the login page.</p>
<p>2. Login with the default user.</p>
<p>The actual code looks just like that.&#160; It should always be a 1 to 1 mapping.</p>
<p>This is where having someone that has some experience doing this is going to come in handy.</p>
<p>Just keep in mind the whole time your 2 big goals:</p>
<ol>
<li>Easy to write tests</li>
<li>Tests are concise</li>
</ol>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1275/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1275&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/03/16/getting-up-to-bat-designing-an-automation-framework/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/03/unnamed_thumb.jpg" medium="image">
			<media:title type="html">unnamed</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/03/automated_testing_framework-2_thumb.png" medium="image">
			<media:title type="html">automated_testing_framework-2</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Up to BAT: Picking a Browser Automation Tool</title>
		<link>http://simpleprogrammer.com/2011/03/06/getting-up-to-bat-picking-a-browser-automation-tool/</link>
		<comments>http://simpleprogrammer.com/2011/03/06/getting-up-to-bat-picking-a-browser-automation-tool/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 03:00:30 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BAT]]></category>
		<category><![CDATA[Functional]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1267</guid>
		<description><![CDATA[Now that you’ve gotten an “Automation Lead” for your BAT (Black-box Automated Testing,) it&#8217;s time to make a very important decision. It is time to pick the browser automation tool you are going to use for driving your automation efforts. Before we can build an automation framework, we need a basic set of tools to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1267&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now that you’ve gotten an “Automation Lead” for your BAT (Black-box Automated Testing,) it&#8217;s time to make a very important decision.</p>
<p>It is time to pick the browser automation tool you are going to use for driving your automation efforts.</p>
<p>Before we can build an automation framework, we need a basic set of tools to build it on.&#160; We want our automation framework to be tailored to our application under test specifically.&#160; Our automation framework will act like a Domain Specific Language (DSL) for testing our application, but we need to build that automation framework on top of something.</p>
<h2>What is a browser automation tool?</h2>
<p>It is essentially what we will use to drive the web browser.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/03/older_driver.jpg"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="BC-WV--BC-PRI--Older Drivers--Eighty-seven-year-old Dorothy Wulfers, who learned to drive a Model T Ford at age 15, prepares to pull out of her parking space Friday, June 4, 2004 in Morgantown, WV. Wulfers said only her and God will decide when she stops driving. (AP PHOTO/DALE SPARKS)" border="0" alt="BC-WV--BC-PRI--Older Drivers--Eighty-seven-year-old Dorothy Wulfers, who learned to drive a Model T Ford at age 15, prepares to pull out of her parking space Friday, June 4, 2004 in Morgantown, WV. Wulfers said only her and God will decide when she stops driving. (AP PHOTO/DALE SPARKS)" src="http://complextosimple.files.wordpress.com/2011/03/older_driver_thumb.jpg?w=491&#038;h=325" width="491" height="325" /></a></p>
<p>We need to pick a tool or framework that will easily allow us to interact with the web browser so we don’t have to write that code ourselves.</p>
<p>We will need to be able to click buttons, enter text, select drop downs, and check values on web pages.</p>
<p>Some of the things we will want to consider when choosing a browser automation tool include:</p>
<ul>
<li>Language we can use with the driver </li>
<li>Browsers it supports </li>
<li>How we interact with the browser (do we use XPath, JQuery, or some other mechanism) </li>
<li>If we can access and manipulate everything we need to be able to in the browser </li>
<li>Speed of execution </li>
<li>Ability to execute in parallel </li>
<li>Support and future development </li>
</ul>
<p>Let’s take a quick look at each of these considerations.</p>
<p><strong>What language can we use?</strong></p>
<p>This is an important consideration because you will want to be able to utilize your other programming resources to help with building an automation framework and to eventually create automation tests.</p>
<p>If you pick a browser driver that supports a language your regular programmers don’t like, or don’t know, you may not end up with their support, and you are definitely going to want their support.</p>
<p><strong>What browsers does it support?</strong></p>
<p>This is a tricky topic to discuss.&#160; It might seem that a browser automation tool would need to support all of the browsers your application supports, but that is not really true.</p>
<p>You really have to think about what your goal is with your BATs.&#160; I could certainly devote a whole blog post to this topic, but I will try and summarize my main point here.</p>
<p>BATs should be designed to test functionality of the application, not to test compatibility.&#160; (At least most of your BATs should be, although you might have some that are specifically for compatibility.)&#160; With that goal in mind, a browser driver supporting each and every browser your application supports is not really necessary.</p>
<p>You do need to consider that the browser automation tool should support at least one of your supported browsers, preferably the main one.</p>
<p><strong>How do we interact with the browser?</strong></p>
<p>There are several different APIs which are used to communicate with the web browser that are employed by various different browser drivers.</p>
<p>Some tools have APIs that are very low level and allow you to very easily manipulate objects in the web browser while others are at a much higher level and rely more on your understanding of the brower’s DOM.</p>
<p>For example, one API might expose elements on a web page by their actual element name and let you interact with them directly.</p>
<p><em>browser.Button(Find.ByName(“submitButton”)).Click();</em></p>
<p>vs</p>
<p><em>instance.click(“submitButton”);</em></p>
<p>In the first example, the API is aware of element types like buttons.&#160; In the second example, the API is more generic and will send a “click” to an element with the ID value you specify.</p>
<p>You’ll have to decide how important the ease of use is to your project at this level.&#160; There are some tradeoffs to consider here.</p>
<p>The lower level the API is, the easier it will be to use, but the more dependent you will be on that API and the more language specific that API will be.</p>
<p>The higher level the API is, the harder it will be to use, but it will free you from depending so much on the API, because you will be interacting more directly with the browser’s DOM.</p>
<p>I prefer lower level APIs because I find that it is much easier to write the framework code on top of these.</p>
<p>You will also want to consider here the skill levels of the programmers who will be creating the framework.&#160; If your API is lower level, native language skills are more important.&#160; If it is higher level, DOM and HTML, and perhaps Javascript skills, are more important.</p>
<p><strong>Can we access what we need?</strong></p>
<p>If your application makes use of Javascript pop-up dialogs and your browser automation tool doesn’t give you a way to interact with them, you don’t want to find this out when you have already invested significantly into your automation framework.</p>
<p>Different automation frameworks support different features of browser; not all of them will allow you to interact with every single browser feature that exists.&#160; As new features are introduced, you could also get stuck with a tool that is no longer being maintained and doesn’t add support for the new features.</p>
<p>You will want to consider things like how much your application uses AJAX or JQuery.&#160; You will want to select a browser automation tool which would make it easy to interact with AJAX calls if your application relies on them heavily.</p>
<p><strong>Speed of execution</strong></p>
<p>Not all browser automation tools are the same in execution speed either.</p>
<p>This may not be important to you, depending on how you address the issue of concurrency, but you should at least consider that if you have a large number of automated tests, a small difference in execution speed can result in a large difference in total time to run the tests.</p>
<p>The faster the automated tests can be run, the more valuable they are.&#160; I won’t get into the details here but there are many reason why this is true.</p>
<p>Also influencing the speed in which you can run your tests will be if you automation tool choice requires you to put pauses into the test to wait for the browser instead of responding to events that occur in the browser.</p>
<p><strong>Ability to execute in parallel</strong></p>
<p>This consideration will depend greatly on the volume of and speed in which your tests can execute.</p>
<p>At some time (sooner than you think) you will likely get to the point where you can no longer run all of your automated tests in 24 hours.&#160; Perhaps even before this point, you will want to consider running your BATs in parallel to reduce the total time to execute the tests.</p>
<p>Some automation tools have built-in support and others will require you to build your own way to do this.&#160; It is good to at least have an idea of how you are going to achieve parallel execution when considering what browser automation tool to use.</p>
<p><strong>Support and future development</strong></p>
<p>We are in a pretty rapid pace of browser development.&#160; Many things in the web browser world are changing much more rapidly than ever before.&#160; Tools to automate the browser must also change or you could end up in a very bad place.</p>
<p>If your application is going to take advantage of the latest browsers and browser features, you should make sure the automation tool you choose is in active development.</p>
<p>There is nothing worse than investing into an open-source project and then having that project die, resulting in you having to rip it out to replace it with another library.</p>
<p>You can always design your automation framework to be abstracted away as much as possible from the underlying browser driver, but that will be extra work, so consider this point carefully.</p>
<h2>Name names sir!</h2>
<p>Nope, I’m not going to do it.</p>
<p>I’m not going to tell you to use Watin or Watij or Selenium or WebAii or any other browser driver.&#160; I don’t want to put the focus on the tool, since the real focus will be building the automation framework on top of the tool you use to drive the browser.</p>
<p>I would suggest that you try writing a few simple tests in each of the major browser drivers so that you can get a good feel of what the API is like and how it will work with your application.</p>
<p>I will say that I have used most of the major choices out there and there really is no clear winner in my mind.&#160; It really is going to depend on what your environment is like and what kind of application you are testing.</p>
<p>I would also recommend picking a browser driver and sticking to it.&#160; I’ve tried in the past to abstract away the browser driver from the automation framework and while it is possible, it can become quite messy and add quite a bit of overhead to your project.</p>
<p>My only other hints would be to not put too much emphasis on supporting multiple browsers or on using recording tools.&#160; Neither of these things will benefit you much in the long run because you will find that you will not want to try and run all of your BATs on each browser. Recording tools will not be nearly as effective as writing your own custom framework (which I will talk about in my next post.)</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1267&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/03/06/getting-up-to-bat-picking-a-browser-automation-tool/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/03/older_driver_thumb.jpg" medium="image">
			<media:title type="html">BC-WV--BC-PRI--Older Drivers--Eighty-seven-year-old Dorothy Wulfers, who learned to drive a Model T Ford at age 15, prepares to pull out of her parking space Friday, June 4, 2004 in Morgantown, WV. Wulfers said only her and God will decide when she stops driving. (AP PHOTO/DALE SPARKS)</media:title>
		</media:content>
	</item>
		<item>
		<title>Back to Basics: Becoming BAT Man</title>
		<link>http://simpleprogrammer.com/2011/02/05/back-to-basics-becoming-bat-man/</link>
		<comments>http://simpleprogrammer.com/2011/02/05/back-to-basics-becoming-bat-man/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 06:47:15 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Functional]]></category>
		<category><![CDATA[Process Improvement]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[User]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1249</guid>
		<description><![CDATA[In my Back to Basics post on my conclusions about blackbox automated tests (BATs) and unit testing, I said that we should: Spend a majority of your effort, all the time you would have spent writing unit tests, instead writing what I will call blackbox automated tests or BATs. In this post, I am going [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1249&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my Back to Basics post on my <a href="http://simpleprogrammer.com/2011/01/14/back-to-basics-unit-testing-automated-blackbox-testing-and-conclusions/">conclusions about blackbox automated tests (BATs)</a> and unit testing, I said that we should:</p>
<blockquote><p>Spend a majority of your effort, all the time you would have spent writing unit tests, instead writing what I will call blackbox automated tests or BATs.</p>
</blockquote>
<p>In this post, I am going to outline what I think it takes for a team to go from BAT-less to BAT-man (or BAT-woman) without going batty.</p>
<p>I want to take a practical approach to getting from 0 blackbox automated tests to building a sustainable process of developing BATs as a integral component of the acceptance criteria for calling a backlog item “done.”</p>
<h2>Let me paint a picture for you</h2>
<p><a href="http://complextosimple.files.wordpress.com/2011/02/human-paint-brush.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="human-paint-brush" border="0" alt="human-paint-brush" src="http://complextosimple.files.wordpress.com/2011/02/human-paint-brush_thumb.jpg?w=484&#038;h=503" width="484" height="503" /></a></p>
<p>I want to paint the picture for you of the end goal that we are seeking to achieve, from start to finish, of a single backlog.</p>
<ol>
<li>A backlog is selected for work. </li>
<li>Developers, QA and product owner work together to clearly define the acceptance criteria which will enable that backlog to be signed off or called “done.” </li>
<li>QA and developers work together to transform the acceptance criteria into a high level description of BATs which will be created to verify each aspect of the acceptance criteria. </li>
<li>Developer begins coding with this high level set of BATs in mind (BATs drive the development), QA begins developing BATs. </li>
<li>As developer completes enough functionality to pass a BAT and not break existing BATs that functionality is checked into trunk. </li>
<li>Each check-in causes the entire battery of BATs to be kicked off split across multiple VMs which run 100s of hours worth of automated tests in minutes. </li>
<li>Once all BATs for a backlog are passing, that backlog is done and those BATs become part of the battery of tests which are run with each continuous integration build. </li>
</ol>
<p>We should keep this simple process in mind and strive to reach it, knowing that when we are able to reach this process we will be able to have a HUGE amount of confidence in the functionality and non-regression of our system.</p>
<p>Put aside for a second your notion that unit testing is the correct thing to do.&#160; Put aside the idea that blackbox automated testing is too hard and too fragile, and imagine the world of software development that flows like the picture I painted above.</p>
<p>Now listen up, because this part is important…</p>
<p><strong>Before you put forth the effort to write one more unit test, before you dip your test double pen in the ink well of “mock,” make sure you are first taking efforts to develop a process to create BATs.</strong></p>
<h2></h2>
<h2></h2>
<h2>The value proposition</h2>
<p>We really need to take the effort to understand the value proposition being presented here.</p>
<p>I’m going to use some real fake numbers to try and really convey this important point that I think is likely to be overlooked.</p>
<p>Consider first the amount of time that you spend doing two things:</p>
<ol>
<li>Creating infrastructure to allow your code to be unit tested in isolation.&#160; (Dependency injection, interfaces, etc.) </li>
<li>Time spent writing unit tests. </li>
</ol>
<p>Now, before we go any further, I just want to reiterate.&#160; I am not advocating completely abolishing the writing of unit tests.&#160; See my <a href="http://simpleprogrammer.com/2011/01/14/back-to-basics-unit-testing-automated-blackbox-testing-and-conclusions/">original conclusions post</a>, or my post on <a href="http://simpleprogrammer.com/2011/01/23/back-to-basics-unit-testing-without-mocks/">unit testing without mocks</a> for a better understanding of what I am advocating in regards to unit testing.</p>
<p>So back to my point.&#160; Think about all the time it takes to do this.&#160; To properly isolate and unit test code most developers would probably estimate that for every hour worth of work writing the code there is about another hour to two hours worth of unit testing and unit test prep time.</p>
<p>There is a reason why unit tests take longer to write than the code they test; it takes MORE lines of code to test a line of code in isolation.</p>
<p>BATs developed using a good automation framework are just the opposite.&#160; While unit test code might have a ratio of 4 lines of unit test code to 1 line of production code or a 4:1 ratio, BAT code has a completely opposite ratio.&#160; It is very likely that 1 line of BAT code can test 20 lines or more of production code, a 1:20 ratio.&#160; (Where do I get these numbers?&#160; Looking at some of my real production code being tested with unit tests and BATs.)</p>
<p><strong>Even if unit tests and BATs were equally effective in preventing the regression of your software system, and equally effective at providing an absolute assurance of meeting the acceptance criteria (which I would argue that BATs are much more effective at both), you can see easily that you are going to get a much higher return on your investment by investing your time in BATs vs. investing your time in unit tests.</strong></p>
<p>I don’t make these statements lightly or in a theoretical tone.&#160; I have real world experience with successfully implementing automation frameworks for writing BATs that reinforce these conclusions.</p>
<h2>How to get there</h2>
<p>If I have done my job, you are now at least convinced that getting to the point of having BATs for all backlogs is a good goal, but if you are like most people I talk to, you are skeptical of the costs and feasibility of doing it.</p>
<p>What you need is a good guide.&#160; A step by step guide on how to do it.</p>
<p>I am going to conclude the Back to Basics posts and segue into a new series with the goal of providing a step by step guide to getting to fully automated blackbox testing.</p>
<p>Let’s take a look at the steps that I will cover in the next series of posts.</p>
<ol>
<li><strong>Hiring an automation lead</strong> – it’s important to either find someone who’s done this before, or a developer resource to this role. </li>
<li><strong>Deciding on the underlying browser driver or browser automation tool – </strong>assuming web apps here, there are several to choose from, WatiX, Selenium and more. </li>
<li><strong>Designing an automation framework –</strong> building a framework tailored specifically to your application under test will create an effective domain specific language for testing your application. </li>
<li><strong>Creating your first smoke tests –</strong> building some smoke tests will help you prove and build out your framework and provide you the highest value tests first. </li>
<li><strong>Adding smoke tests to your build –</strong> with smoke tests being run as part of the build, you can immediately start seeing value. </li>
<li><strong>Adding BATs to your acceptance criteria –</strong> we need to start out slowly here, but eventually make all backlogs require BATs for each acceptance criterion. </li>
<li><strong>Scaling out –</strong> as you start to get a large amount of BATs you’ll need to figure out a way to virtualize more servers and parallelize the test runs to be able to run all the BATs in a short amount of time. </li>
<li><strong>Building a true DSL –</strong> once you get this far, it may be time to start thinking about creating a domain specific language that even business analysts can write tests with. </li>
</ol>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1249/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1249/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1249&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/02/05/back-to-basics-becoming-bat-man/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/02/human-paint-brush_thumb.jpg" medium="image">
			<media:title type="html">human-paint-brush</media:title>
		</media:content>
	</item>
		<item>
		<title>Back to Basics: Unit Testing, Automated Blackbox Testing, and Conclusions!</title>
		<link>http://simpleprogrammer.com/2011/01/14/back-to-basics-unit-testing-automated-blackbox-testing-and-conclusions/</link>
		<comments>http://simpleprogrammer.com/2011/01/14/back-to-basics-unit-testing-automated-blackbox-testing-and-conclusions/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 14:24:50 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Functional]]></category>
		<category><![CDATA[Process Improvement]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[User]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2011/01/14/back-to-basics-unit-testing-automated-blackbox-testing-and-conclusions/</guid>
		<description><![CDATA[If you’ve been following me from the beginning of the Back to Basics series, you’ll know that I set out to reevaluate some of the commonly held truths of what best practices are, especially in regards to unit testing, dependency injection and inversion of control containers. We’ve talked about what an interface is, cohesion and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1225&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you’ve been following me from the <a href="http://simpleprogrammer.com/2010/10/30/getting-back-to-basics-introduction-and-why/">beginning</a> of the <a href="http://simpleprogrammer.com/back-to-basics-series/">Back to Basics series</a>, you’ll know that I set out to reevaluate some of the commonly held truths of what best practices are, especially in regards to unit testing, dependency injection and inversion of control containers.</p>
<p>We’ve talked about <a href="http://simpleprogrammer.com/2010/11/02/back-to-basics-what-is-an-interface/">what an interface</a> is, <a href="http://simpleprogrammer.com/2010/11/04/back-to-basics-cohesion-and-coupling-part-1/">cohesion and coupling</a>, and even went a little bit off track to talk about <a href="http://simpleprogrammer.com/2010/12/07/back-to-basics-sorting/">sorting</a> for a bit.</p>
<p>One of the reoccurring themes that kept showing up in most of the posts was unit testing.&#160; I talked about <a href="http://simpleprogrammer.com/2010/12/12/back-to-basics-why-unit-testing-is-hard/">why unit testing is hard</a>, and I defined three levels of unit testing.</p>
<ul>
<li><strong>Level 1</strong> &#8211; we have a single class with no external dependencies and no state.&#160; We are just testing an algorithm.</li>
<li><strong>Level 2</strong> &#8211; we have a single class with no external dependencies but it does have state.&#160; We are setting up an object and testing it as a whole.</li>
<li><strong>Level 3</strong> &#8211; we have a single class with at least one external dependency, but it does not depend on its own internal state.</li>
<li><strong>Level 4</strong> &#8211; we have a single class with at least one external dependency and depends on its own internal state.</li>
</ul>
<p>Throughout this series I ended up tearing down using interfaces with only single non-unit test implementation.&#160; I criticized the overuse of dependency injection for the sole purpose of unit testing.&#160; I attacked a large portion of best practices that I felt were only really being used in order to be able to unit test classes in isolation.</p>
<p>But, I never offered a solution.&#160; I told you what was bad, but I never told you what was good.</p>
<p>I said don’t create all these extra interfaces, use IoC containers all over your app, and mocks everywhere just for the purpose of being able to isolate a class you want to unit test, but when you asked me what to do instead, I said “I don’t know, I just know what we are doing is wrong and we need to stop.”</p>
<p>Well, that is no answer, but I intend to give one now.&#160; I’ve been thinking about this for months, researching the topic and experimenting on my own.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/01/cool-experiment.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="cool experiment" border="0" alt="cool experiment" src="http://complextosimple.files.wordpress.com/2011/01/cool-experiment_thumb.jpg?w=488&#038;h=390" width="488" height="390" /></a></p>
<h2>I finally have an answer</h2>
<p>But, before I give you it, I want to give you a little background on my position on the subject matter.</p>
<p>I come from a pretty solid background of unit testing and test driven development.&#160; I have been preaching both for at least the last 7 years.</p>
<p>I was on board from the beginning with dependency injection and IoC containers.&#160; I had even rolled my own as a way to facilitate isolating dependencies for true unit tests.</p>
<p>I think unit testing and TDD are very good skills to have.&#160; I think everyone should learn them.&#160; TDD truly helps you write object oriented code with small concentrated areas of responsibility.</p>
<p>But, after all this time I have finally concluded, for the most part, that unit tests and practicing TDD in general do more good for the coder than the software.</p>
<p>What?&#160; How can I speak such blasphemy?</p>
<p>The truth of the matter is that I have personally grown as a developer by learning and practicing TDD, which has lead me to build better software, but not because the unit tests themselves did much.&#160; </p>
<p>What happened is that while I was feeling all that pain of creating mocks for dependencies and trying to unit test code after I had written it, I was learning to reduce dependencies and how to create proper abstractions.&#160; </p>
<p>I feel like I learned the most when the IoC frameworks were the weakest, because I was forced to minimize dependencies for the pain of trying to create so many mocks or not being able to unit test a class in isolation at all.</p>
<p>I’ve gotten to the point now where two things have happened:</p>
<ol>
<li>I don’t need the TDD training wheels anymore.&#160; I don’t pretend to be a coding god or demi-god of some sort, but in general the code I write that is done in a TDD or BDD style is almost exactly the same as the code I write without it.</li>
<li>The IoC containers have made it so easy to pass 50 dependencies into my constructor that I am no longer feeling the pain that caused my unit tests to cause me to write better code.</li>
</ol>
<p>What I find myself ending up with now when I write unit tests is 70% mocking code that verifies that my code calls certain methods in a certain order.</p>
<p>Many times I can’t even be sure if my unit test is actually testing what I think it is, because it is so complex.</p>
<h2>Umm, did you say you had an answer, dude?</h2>
<p>Yes, I do have an answer.&#160; I just wanted to make sure you understand where I am coming from before I throw out all these years of practical knowledge and good practices.</p>
<p><strong>I am not the enemy.</strong></p>
<p>My answer to the problem of what to do if you shouldn’t be using IoC containers and interfaces all over your code base just for the purpose of unit testing, is to take a two pronged approach.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/01/2prong.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="2prong" border="0" alt="2prong" src="http://complextosimple.files.wordpress.com/2011/01/2prong_thumb.jpg?w=480&#038;h=480" width="480" height="480" /></a></p>
<ol>
<li>Mostly only write level 1 or level 2 unit tests.&#160; Occasionally write level 3 unit tests if you only have 1 or possibly 2 dependencies.&#160; (I’ll talk about more how to do this in my next post)</li>
<li>Spend a majority of your effort, all the time you would have spent writing unit tests, instead writing what I will call blackbox automated tests or BATs.&#160; (I used to call this automated functional tests, but I think that name is too ambiguous.)</li>
</ol>
<p>I intend to drill really deep into these approaches in some upcoming posts, but I want to briefly talk about why I am suggesting these two things in place of traditional BDD or TDD approaches.</p>
<h2>What are the benefits?</h2>
<p><strong>The first obvious benefit is that you won’t be complicating your production code with complex frameworks for injecting dependencies and other clever things that really amount to making unit testing easier.</strong></p>
<p>Again, I am not saying you shouldn’t ever use dependency injection, interfaces or IoC containers.&#160; I am just saying you should use them when they provide a real tangible value (which most of the time is going to require alternate non-unit test implementations of an interface.)</p>
<p>Think about how much simpler your code would be if you just went ahead and new’d up a concrete class when you needed it.&#160; If you didn’t create an extra interface for it, and then pass it in the constructor.&#160; You just used it where you needed it and that was that.</p>
<p><strong>The second benefit is that you won’t spend so much time writing hard unit tests.</strong>&#160; I know that when I am writing code for a feature I usually spend at least half the amount of time writing unit tests.&#160; This is mostly because I am writing level 3 and level 4 unit tests, which require a large number of mocks.</p>
<p>Mocks kill us.&#160; Mocking has a negative ROI.&#160; Not only is creating them expensive in terms of time, but it also strongly couples our test classes to the system and makes them very fragile.&#160; Plus, mocking adds huge amounts of complexity to unit tests.&#160; Mocking usually ends up causing our unit test code to become unreadable, which makes it almost worthless.</p>
<p>I’ve been writing mocks for years.&#160; I know just about every trick in the book.&#160; I can show you how to do it in Java, in C#, even in C++.&#160; It is always painful, even with auto-mocking libraries.</p>
<p>By skipping the hard unit tests and finding smart ways to make more classes only require level 1 and level 2 unit tests, you are making your job a whole lot easier and maximizing on the activities that give you a high ROI.&#160; Level 1 and level 2 unit tests, in my estimation, give very high ROIs.</p>
<p><strong>The thirds benefit is that blackbox automated tests are the most valuable tests in your entire system and now you’ll be writing more of them.&#160; </strong>There are many names for these tests, I am calling them BATs now, but basically this is what most companies call automation.&#160; Unfortunately, most companies leave this job to a QA automation engineer instead of the development teams.&#160; Don’t get me wrong, QA automation engineers are great, but there aren’t many of them, good ones are very expensive, and the responsibility shouldn’t lie squarely on their shoulders.</p>
<p>BATs test the whole system working together.&#160; BATs are your automated regression tests for the entire system.&#160; BATs are automated customer acceptance tests and <strong>the ROI for each line for code in a BAT can be much higher than the ROI of each line of production code.</strong></p>
<p>Why?&#160; How is this even possible?&#160; It’s all about leverage baby.&#160; Each line of code in a BAT may be exercising anywhere from 5 to 500 lines of production code, which is quite the opposite case of a unit test where each line of unit test code might only be testing a 1/8th or 1/16th a line of production code on average (depending on code coverage numbers being reached.)</p>
<p>I’ll save the detail for later posts, but it is my strong opinion that a majority of a development teams effort should be put in BATs, because BATs</p>
<ul>
<li>Have high value to the customer</li>
<li>Regression test the entire system</li>
<li>Have a huge ROI per line of code (if you create a proper BAT framework)</li>
</ul>
<p>Imagine how much higher quality your software would be if you had a BAT for each backlog item in your system which you could run every single iteration of your development process.&#160; Imagine how confident you would be in making changes to the system, knowing that you have an automated set of tests that will catch almost any break in functionality.</p>
<p>Don’t you think that is worth giving up writing level 3 and level 4 unit tests, which are already painful and not very fun to begin with to achieve?</p>
<p>In my future posts on the Back to Basics series, I will cover in-depth how to push more of your code into level 1 and level 2 unit tests by extracting logic out to separate classes that have no dependencies, and I will talk more about BATs, and how to get started and be successful using them.&#160; (Hint: you need a good BAT framework.)</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1225&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/01/14/back-to-basics-unit-testing-automated-blackbox-testing-and-conclusions/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/01/cool-experiment_thumb.jpg" medium="image">
			<media:title type="html">cool experiment</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/01/2prong_thumb.jpg" medium="image">
			<media:title type="html">2prong</media:title>
		</media:content>
	</item>
	</channel>
</rss>
