<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6716341810029282254</atom:id><lastBuildDate>Mon, 09 Sep 2024 13:45:38 +0000</lastBuildDate><category>.NET</category><category>C#</category><category>data driven testing</category><category>software development</category><category>unit testing</category><title>How Fragile Is Your Agile?</title><description>A collection of tips, tricks, and lessons learned to help your team gain the necessary &lt;i&gt;confidence while committing&lt;/i&gt; their code. Topics covered range from continuous integration to software development methodologies.</description><link>http://fragileagile.blogspot.com/</link><managingEditor>noreply@blogger.com (Mike Jensen)</managingEditor><generator>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6716341810029282254.post-192208147201504947</guid><pubDate>Sat, 23 Sep 2006 23:18:00 +0000</pubDate><atom:updated>2006-09-23T16:25:09.297-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.NET</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">data driven testing</category><category domain="http://www.blogger.com/atom/ns#">software development</category><category domain="http://www.blogger.com/atom/ns#">unit testing</category><title>Data Driven Testing - Part 1</title><description>&lt;span style=&quot;font-family:arial;&quot;&gt;It&#39;s 3am, you&#39;ve been working all night on a new feature, and you&#39;re about to commit your code for QA testing; you ask yourself &lt;/span&gt;&lt;span style=&quot;font-style: italic;font-family:arial;font-size:100%;&quot;  &gt;is this going to work?&lt;/span&gt;&lt;span style=&quot;;font-family:arial;font-size:100%;&quot;  &gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;We&#39;ve all been there. No one likes their work being rejected, or being known as the developer that commits faulty code. Worse yet, the bug sneaks past the testers and is discovered months after it has been in production.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;So, how do we &lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:arial;&quot; &gt;prove&lt;/span&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; our code works before we commit it into the next build? I hope you all said &lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:arial;&quot; &gt;Unit Tests&lt;/span&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;. There are many different unit testing patterns outlined at &lt;/span&gt;&lt;a style=&quot;font-family: trebuchet ms;&quot; href=&quot;http://xunitpatterns.com/&quot;&gt;XUnit Test Patterns&lt;/a&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;. This post focuses on how to maximize the test coverage of your &lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:arial;&quot; &gt;data dependent&lt;/span&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; .NET components with minimal code. Sound good? Then lets get to it.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;You may be asking yourself, what is a &lt;/span&gt;&lt;span style=&quot;font-weight: bold;font-family:arial;&quot; &gt;data dependent&lt;/span&gt;&lt;span style=&quot;font-family:arial;&quot;&gt; component? In short, it is a component that takes a finite set of input values and has produces a discrete output based on those values. In the example below, we have a postal address class that has complex validation rules (region based on the country, postal/zip code based on country, etc.). I am assuming you are all familiar with &lt;a href=&quot;http://www.nunit.org/&quot;&gt;NUnit&lt;/a&gt;; I have recently started using the &lt;a href=&quot;http://www.mertner.com/confluence/display/MbUnit/Home&quot;&gt;MBUnit&lt;/a&gt; test framework as it is a lot easier to test data dependent components.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;table class=&quot;code&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;[RowTest]&lt;br /&gt;[Row( &lt;span class=&quot;String&quot;&gt;&quot;1234 Some Street&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;Vancouver&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;V9V 9V9&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;BC&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;CA&quot;&lt;/span&gt;, &lt;span class=&quot;Keyword&quot;&gt;true&lt;/span&gt; )]&lt;br /&gt;[Row( &lt;span class=&quot;String&quot;&gt;&quot;1234 Some Street&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;Vancouver&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;V9V 9V9&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;BC&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;US&quot;&lt;/span&gt;, &lt;span class=&quot;Keyword&quot;&gt;false&lt;/span&gt; )]&lt;br /&gt;[Row( &lt;span class=&quot;String&quot;&gt;&quot;&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;Vancouver&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;V9V 9V9&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;BC&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;CA&quot;&lt;/span&gt;, &lt;span class=&quot;Keyword&quot;&gt;false&lt;/span&gt; )]&lt;br /&gt;[Row( &lt;span class=&quot;String&quot;&gt;&quot;1111 Rich Drive&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;Beverly Hills&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;90210&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;CA&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;US&quot;&lt;/span&gt;, &lt;span class=&quot;Keyword&quot;&gt;true&lt;/span&gt; )]&lt;br /&gt;[Row( &lt;span class=&quot;String&quot;&gt;&quot;1234 Some Street&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;Vancouver&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;90210&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;BC&quot;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&quot;CA&quot;&lt;/span&gt;, &lt;span class=&quot;Keyword&quot;&gt;false&lt;/span&gt;)]&lt;br /&gt;&lt;span class=&quot;Modifier&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;ValueType&quot;&gt;void&lt;/span&gt; TestPostalAddressValidation( &lt;span class=&quot;ReferenceType&quot;&gt;string&lt;/span&gt; streetAddress, &lt;span class=&quot;ReferenceType&quot;&gt;string&lt;/span&gt; city,&lt;br /&gt;                                  &lt;span class=&quot;ReferenceType&quot;&gt;string&lt;/span&gt; postalZipCode, &lt;span class=&quot;ReferenceType&quot;&gt;string&lt;/span&gt; region,&lt;br /&gt;                                  &lt;span class=&quot;ReferenceType&quot;&gt;string&lt;/span&gt; country, &lt;span class=&quot;ValueType&quot;&gt;bool&lt;/span&gt; isValid )&lt;br /&gt;{&lt;br /&gt;PostalAddress address = &lt;span class=&quot;Keyword&quot;&gt;new&lt;/span&gt; PostalAddress();&lt;br /&gt;address.StreetNo = streetAddress;&lt;br /&gt;address.StreetAddress = streetAddress;&lt;br /&gt;address.City = city;&lt;br /&gt;address.PostalZipCode = postalZipCode;&lt;br /&gt;address.Region = region;&lt;br /&gt;address.Country = country;&lt;br /&gt;&lt;br /&gt;ValidationResult result = address.Validate();&lt;br /&gt;Assert.AreEqual( isValid, result.IsValid, &lt;span class=&quot;String&quot;&gt;&quot;The Error Message is {0}&quot;&lt;/span&gt;, result.Message );&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;The above code snippet demonstrates how you can abstract your data input from your test code. As you can see, we expect our postal address validation to catch the following problems:&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;a region that does not belong to the given country&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;a postal/zip code that does not match the appropriate format for the given country&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;missing data&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&quot;font-family:arial;&quot;&gt;Although this example may seem trivial, I wanted to start with a gentle example. You may be thinking - &lt;span style=&quot;font-style: italic;&quot;&gt;I&#39;d have to setup hundreds of Row attributes to cover all of the possible validation combinations&lt;/span&gt;. In my next post, I will show you how to handle this in a much more efficient manner.&lt;br /&gt;&lt;br /&gt;If there are any data driven testing topics you&#39;d like to see in a future post, please let me know.&lt;br /&gt;&lt;/span&gt;</description><link>http://fragileagile.blogspot.com/2006/09/data-driven-testing-part-1.html</link><author>noreply@blogger.com (Mike Jensen)</author><thr:total>0</thr:total></item></channel></rss>