1 2 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 3 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"'> 4 <html> 5<head xmlns='http://www.w3.org/1999/xhtml'><title>index at XUnitPatterns.com </title>
6<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> 7</script>
vendor: 1 bytes, line 7
7
8<script type="text/javascript"> 9_uacct = "UA-2890370-2"; 10urchinTracker(); 11</script>
11 12 13</head><body> 14<link href='style.css' rel='StyleSheet' type='text/css' /> 15<div id='topbar'> 16<div id='breadcrumbs'>You are here: <a href='index.html' class='breadcrumbs'>Home</a> > <a href='Web Site Instructions.html' class='breadcrumbs'>Web Site Instructions</a> > XUnit Test Patterns</div> 17<div id='sitename'><span class='logo'>xUnit Patterns</span>.com</div> 18<div id='sitehost'><span class='hosttext'>Hosted by:</span><a href='http://www.xprime.com.au'><img src='xprime Logo.gif' height='50' align='middle' width='150'></img></a></div> 19<div id='tagline'>Unit testing expertise at your fingertips!</div> 20 <!-- SiteSearch Google --> 21 <form id="search" method="get" action="http://www.google.com/custom" target="google_window"> 22 <table border="0" bgcolor="#ffffff"> 23 <tr class="tight"> 24 <td class="tight" nowrap="nowrap" valign="top" align="left"></td> 25 <td class="tight" nowrap="nowrap"> 26 <input type="hidden" name="domains" value="xunitpatterns.com"></input> 27 <label for="sbi" style="display: none">Enter your search terms</label> 28 <input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input> 29 </td> 30 </tr><tr> 31 <td class="tight"> </td> 32 <td class="tight" nowrap="nowrap"> 33 <table> 34 <tr> 35 <td class="tight"> 36 <input type="radio" name="sitesearch" value="" checked id="ss1"></input> 37 <label for="ss0" title="Search the Web"><font size="-1" color="#000000">Web</font></label> 38 </td> 39 <td class="tight"> 40 <input type="radio" name="sitesearch" value="xunitpatterns.com" id="ss0"></input> 41 <label for="ss1" title="Search xunitpatterns.com"><font size="-1" color="#000000">xunitpatterns.com</font></label> 42 </td> 43 </tr> 44 </table> 45 <label for="sbb" style="display: none">Submit search form</label> 46 <input type="submit" name="sa" value="Google Search" id="sbb"></input> 47 <input type="hidden" name="client" value="pub-2548472458685803"></input> 48 <input type="hidden" name="forid" value="1"></input> 49 <input type="hidden" name="ie" value="ISO-8859-1"></input> 50 <input type="hidden" name="oe" value="ISO-8859-1"></input> 51 <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input> 52 <input type="hidden" name="hl" value="en"></input> 53 </td> 54 </tr> 55 </table> 56 </form> 57 <!-- SiteSearch Google --> 58 59<div id='utilities'><a href='index.html'>Home</a><b> | </b><a href='http://groups.yahoo.com/group/xunitpatterns/post'>Discuss </a><b> | </b><a href='Cross References & Lists.html'>Lists</a></div></div> 60 <div id='googleads'> 61
61<script type="text/javascript"><!-- 62 google_ad_client = "pub-2548472458685803"; 63 //728x90, created 11/12/07 64 google_ad_slot = "7681663526"; 65 google_ad_width = 728; 66 google_ad_height = 90; 67 //--></script>
67 68
68<script type="text/javascript" 69 src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 70 </script>
70 71 </div> 72 73<div id='content'> 74<td colspan='3'> 75<p> 76</p><a name='XUnit Test Patterns'></a> 77<h1>XUnit Test Patterns 78</h1> 79<p><span class='emphasis'>Refactoring Test Code</span> 80</p><table><tr><td><a name='xUnit Test Patterns - the book'></a> 81<h3>xUnit Test Patterns - the book 82</h3> 83<p> 84</p> 85<p>The book has won a Jolt Productivity Award in the Best Technical 86 Book category! Here's what the reviewer Rick Wayne said about 87 why the book won the award: 88</p><p class='quote'>Unit testing is hardly news, but simply 89 writing a ton of tests guarantees you no bliss. Gerard Meszaros's 90 xUnit Test Patterns distills and codifies the crucial meta-knowledge 91 to take us to the next level. Why do good tests go bad, and how do 92 you fix them--it's as simple and groundbreaking as that. Smells and 93 antipatterns arise in tests that cripple their maintainability. 94 xUnit Test Patterns exhaustively describes those pathologies and 95 provides the prescription in the catalog format familiar since 1994. 96 But fear not - every motivation and pattern includes at least one 97 source-code example and the explanations are couched in clear, 98 direct language. If you're ready to promote your test code to the 99 same level of care and craftsmanship that you devote to production 100 systems, grab a copy of xUnit Test Patterns and get cracking.</p> 101<p> 102</p> 103<p>Other reviewers have been equally kind: 104</p><p class='quote'> 105 Awesome book must have for any software developer - A. B. Powell 106 </p> 107<p> 108</p><p class='quote'> 109 Our team has been doing TDD for 6 years since the seminal Kent Beck book. 110 We as a team have learnt read and improved our practice over these years but this book has had the most impact on how 2 do TDD properly. 111 It has significantly improved our code and our testing practices. 112 Many of the leasons we learnt where emphasised and standardised in this book. 113 All I can say is that you will save yourself years and years of hard knocks learning if you read this book first. 114 By following the patterns in this book we have been more easily able to implement the principles in Kent's book. 115 -Brett 116 </p> 117<h4>Availability 118</h4> 119<p>The book is now available at retailers and sample chapters are 120 available for download from Addison Wesley Professional's website. It 121 is available in both traditional print form through most booksellers 122 and as a PDF e-book (but only from the AW website.) Note that the 123 material here is now somewhat out of step with the book content because 124 it hasn't been updated based on the results of copy editing. 125</p><a name='xUnit Test Patterns - Live Training and Tutorials'></a> 126<h3>xUnit Test Patterns - Live Training and Tutorials 127</h3> 128<p>I will be presenting tutorials based on this material at various 129 conferences: 130</p><ul> 131<li>---SPLASH 2010 -half-day 132 tutorial -Reno Nevada -October 18, 133 2010 134</li> 135<li>---Much Ado About Agile 2010 -half-day 136 tutorial -Vancouver BC Canada -November 1st, 2010 137</li></ul> 138<p>I will be doing an open-enrollment <a href='training.html' class='Ref'>training</a> course in Calgary, Alberta November 24-25. 139</p> 140<p>I am available to provide on-site <a href='training.html' class='Ref'>training</a> at your place of 141 business. If you don't have enough people to justify a dedicated class, 142 I can augment with additional students by listing it as an open 143 enrollment course here and through <a href='http://agileuniversity.org/trainer.jsp?id=544'>Agile 144 University</a>. Please feel free to suggest venues where you would like 145 to see a course run. Likewise, please send me your suggestions for 146 future conferences. You can reach me by e-mail using the link at the 147 bottom of each page. 148</p> 149<p>Thanks,<br></br>Gerard 150</p></td><td><br/><img src='Cover-Small.gif' style='margin:20px 20px 20px 20px;'></img><br/><span class='note'>Sketch Cover-Small embedded from Cover-Small.gif</span><br/><br></br><br></br><a href='Larger Cover.html' class='Ref'>Larger picture of cover</a></td></tr></table> 151<p>If you are going to order online, using one of these links will get me a small referral fee. 152</p><table><tr><td>USA</td><td>Canada</td><td>UK</td></tr><tr><td><iframe marginheight='0' scrolling='no' marginwidth='0' src='http://rcm.amazon.com/e/cm?t=xuntespat
1520f-2&&o=1&p=8&l=as1&asins=0131495054&fc1=000000&IS2=1<1=_blank&lc1=0000FF&bc1=FFFFFF&bg1=FFFFFF&f=ifr&nou=1' frameborder='0' style='width:120px;height:240px;'></iframe></td><td><iframe marginheight='0' scrolling='no' marginwidth='0' src='http://rcm-ca.amazon.ca/e/cm?t=xuntespat-20&o=15&p=8&l=as1&asins=0131495054&fc1=000000&IS2=1<1=_blank&lc1=0000FF&bc1=FFFFFF&bg1=FFFFFF&f=ifr&nou=1' frameborder='0' style='width:120px;height:240px;'></iframe></td><td><iframe marginheight='0' scrolling='no' marginwidth='0' src='http://rcm-uk.amazon.co.uk/e/cm?t=xunittestpa&t-21&o=2&p=8&l=as1&asins=0131495054&fc1=000000&IS2=1<1=_blank&lc1=0000FF&bc1=FFFFFF&bg1=FFFFFF&f=ifr&nou=1' frameborder='0' style='width:120px;height:240px;'></iframe></td></tr></table> 153<p>Other online booksellers include: 154</p> 155<ul> 156<li><a href='http://www.powells.com/partner/32094/biblio/0131495054'>Powell's Books, 157 Portland, Oregon USA</a> 158</li> 159<li><a href='http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?z=y 160 &EAN=9780131495050&itm=1'> 161 Barnes & Noble, USA </a> 162</li> 163</ul> 164<p>You can also purchase it directly from Addison Wesley Professional 165 at 166</p> 167<ul> 168<li>Hard cover: 169 <a href='http://www.awprofessional.com/bookstore/product.asp?isbn=0131495054'>http://www.awprofessional.com/bookstore/product.asp?isbn=0131495054&rl=1</a> 170 (2 sample chapters are also available here.) 171</li> 172<li>PDF e-book: 173 <a href='http://www.awprofessional.com/bookstore/product.asp?isbn=0321504801'>http://www.awprofessional.com/bookstore/product.asp?isbn=0321504801&rl=1</a> 174</li> 175</ul><a name='Contents Overview'></a> 176<h3>Contents Overview 177</h3> 178<p>The book is organized in 3 major parts. Part I consists of a series of 179 introductory narratives that describe some aspect of test automation using 180 <a href='xUnit.html' class='GlossaryRef'>xUnit</a>. This includes a list of Goals and Principles which are summarized on 181 the left size of this diagram: 182</p><br/><img src='Goals-Smells.gif' style='margin:20px 20px 20px 20px;'></img><br/><span class='note'>Sketch Goals-Smells embedded from Goals-Smells.gif</span><br/> 183<p>Part II describes a number of "test smells" that are symptoms of problems 184 with how we are automating our tests. These symptoms are summarized in the right 185 side of the previous diagram. 186</p> 187<p>Part III contains descriptions of the patterns. The chapters correspond to 188 the major boxes in the following diagram: 189</p><br/><img src='Patterns Summary.gif' style='margin:20px 20px 20px 20px;'></img><br/><span class='note'>Sketch Patterns Summary embedded from Patterns Summary.gif</span><br/> 190<p>The major boxes in each of the preceding diagrams corresponds to a chapter in 191 the corresponding part of the book; they also correspond the "categories" 192 listed in the top left navigation sidebar on this web site. Selecting a category 193 provides a list of patterns or smells in the category and selecting a specific 194 pattern or smell adds a list of aliases, causes and variations of the chosen 195 pattern or smell. 196</p> 197<p>The following diagram summarizes the notation used in these overview 198 diagrams: 199</p><br/><img src='Visual Summary Legend.gif' style='margin:20px 20px 20px 20px;'></img><br/><span class='note'>Sketch Visual Summary Legend embedded from Visual Summary Legend.gif</span><br/> 200<p>Of course, you can access the material in "book order" by starting in 201 <a href='Book Outline.html' class='Ref'>Book Outline</a>. Because so much has changed during the copy 202 editing process, I'll be "abridging" the material on this web site once the book 203 is out. I will, however, keep a brief summary of each pattern & smell on 204 the site as well as many of the cross reference tables. 205</p><a name='Why is Test Automation Important?'></a> 206<h3>Why is Test Automation Important? 207</h3> 208<p>Automated <a href='unit test.html' class='GlossaryRef'>unit tests</a> (a.k.a. "<a href='developer test.html' class='GlossaryRef'>developer tests</a>") and 209 <a href='customer test.html' class='GlossaryRef'>customer tests</a> (a.k.a. "functional tests") are a cornerstone of 210 many agile development methods (such as eXtreme Programming). The availability 211 of automated, self-checking tests allows developers to be much bolder in how 212 they modify existing software. They allow a more evolutionary form of software 213 development that support incremental delivery of functionality to the customer 214 (motto: Deliver early; deliver often!) that speeds up user feedback and improves 215 the quality (both "fitness for purpose" and "software quality") of the softw
215are 216 being built. The techniques are also spreading to less agile development methods 217 via the introduction of "Test Driven Development" as a less extreme process 218 alternative. 219</p> 220<p>Automated test are more repeatable than manual tests because they execute 221 exactly the same way every time. They don't forget things after long weekends 222 and vacations. They don't leave to work on other projects. They don't get sick 223 or run over by a bus. 224</p> 225<p>Automated tests take a lot less effort to run than manual tests. As a result, 226 they are more likely to be run often. The more often the better. Fully 227 assimilated agile developers run their tests pretty well every time they save 228 and compile their code. And any time they need a quick vote of confidence! The 229 tests act as a comforting "safety net" that promises to catch the developer's 230 mistakes. This allows them to work more quickly and with less paranoia and that 231 makes them more productive despite the extra effort involved in writing the 232 tests. 233</p><a name='Why is Test Automation Hard?'></a> 234<h3>Why is Test Automation Hard? 235</h3> 236<p>Cost effective test automation is all about repeatability, maintainability 237 and communication. Repeatability of results requires repeatability of test 238 fixture setup and repeatability of the interactions with the software under 239 test. And that requires interfaces into the software under test that allow you 240 to put it in the right state before the test and to find out what state it is in 241 after the test. And that can be hard. Throw in the need to make the tests easy 242 to understand and easy to maintain and the problem gets even harder. 243</p> 244<p>Automating tests using XUnit is a form of software whether you write the 245 tests before or after the code it tests. But the goals of this test software 246 ("testware") is very different from the software most people are used to 247 writing. Writing it is optional so we can stop writing it or maintaining it at 248 any time. So we need compelling reason to (keep) writing them. And there is a 249 lot to think about when automating tests. How do I interact with the SUT? What 250 is the best way to express the expected outcome? How can I keep tests from 251 breaking each other? How can I ensure the tests will work next week, next month, 252 even next year? How do I test when the software under test depends on software 253 that hasn't been written yet? Or cannot be used in our test environment? Or 254 makes the tests take too long to run? If writing the tests is hard and has 255 little benefit, we just won't do it any more! 256</p><a name='Why Test Automation *Patterns*?'></a> 257<h3>Why Test Automation *Patterns*? 258</h3> 259<p>I have been reading the various conference papers and (mostly JUnit-based) 260 books on test automation for quite some time. Each author seems to have a 261 particular area of interest and favorite techniques. While I don't always agree 262 with their practices, I am always trying to understand why they do it a 263 particular way and *when* it would be more appropriate to use their techniques 264 than the ones I already use. 265</p> 266<p>This is one of the major different between prose that merely explains a 267 technique and a pattern. Patterns help the reader understand the WHY behind each 268 practice so they can make intelligent choices between the alternative patterns 269 (and thereby avoid nasty consequences from surprising them later.) 270</p> 271<p>Some projects are using the XUnit tools to automate regression tests. All of 272 these initiatives are more successful when the test developers have experience 273 building tests. And the next best thing to having experience test automaters on 274 your project (which ClearStream Consulting would be more than happy to supply) 275 is a well-documented set of good test automation practices in the form of 276 patterns. 277</p><a name='Background of this website'></a> 278<h3>Background of this website 279</h3> 280<p>I've assembled this site to catalog the good practices in <a href='xUnit.html' class='GlossaryRef'>xUnit</a> test
281 automation I've encountered over the years. It came about as a result of 282 discussions between me (<a href='The Author.html' class='Ref'>Gerard Meszaros</a>) 283 and Shaun Smith about the testing techniques we found ourselves using over and 284 over again to solve particular <a href='xUnit.html' class='GlossaryRef'>xUnit</a> test automation problems. 285</p> 286<p>We started off by writing a paper <a href='Faster Tests.html' class='ReferencesRef'>[IEAT]</a> that we presented 287 at XP2001 in Sardinia, Italy on techniques that we had used to make our tests 288 run much faster. This led to discussions with the inventors of <a href='Mock Object.html' class='PatternRef'>Mock Objects</a><span class='first-file-ref'> (page X)</span> about whether we were using <a href='Mock Object.html' class='PatternRef'>Mock Objects</a> or 289 some other technique. 290</p> 291<p> We presented another paper <a href='TAM.html' class='ReferencesRef'>[TAM]</a> at XP/Agile Universe 2003 in New 292 Orleans, Louisiana in which we identified a number of smells and the principles 293 we used to avoid them. These built on papers presented in previous XP 294 conferences on the use of <a href='Mock Object.html' class='PatternRef'>Mock Objects</a> and testing of Frameworks. 295 Discussions with other TDD folk convinced us that there was a real need to share 296 and standardize the vocabulary around XUnit-based test automation. Naturally, 297 patterns were the obvious choice for communicating this knowledge. 298</p> 299<p>Since XP/Agile Universe 2003, we have been cataloging all the patterns we 300 regularly use and the obvious alternatives that we have consciously chosen not 301 to use. We have also been looking through the mostly JUnit-based books on test 302 automation to see what others are advocating looking for techniques whether or 303 not they are described as patterns. There is some obvious overlap between the 304 various material but also seem to be considerable gaps and no comprehensive 305 treatment of the topic. As of October 2003, we had identified over 120 patterns 306 ranging from principles and strategies to coding-level idioms! 307</p><a name='Organization of this website'></a> 308<h3>Organization of this website 309</h3> 310<p>I'll be keeping a brief summary of each pattern & smell on the web site 311 once the book is out. The best place to start is with the <a href='Book Outline.html' class='Ref'>Book Outline</a> (or <a href='Book Outline Diagrams.html' class='Ref'>Book Outline Diagrams</a>). 312</p> 313<p>All the information on this website is organized into categories. The 314 categories are accessible via hyperlinks in the "All Categories" box on the left 315 side. Once a category is selected, the pages (patterns, narratives , etc.) 316 within the category can be accessed from the "All <i>categoryName</i>" box that 317 appears below the "All Categories" box. 318</p> 319<h4>The Narratives 320</h4> 321<p>All patterns, smells, etc. are first introduced in a series of narratives 322 that provide an overview of a particular topic area. The narratives are 323 accessible via the special category "Narratives" from the "All Categories" 324 box or from the <a href='Book Outline.html' class='Ref'>Book Outline</a>. 325</p> 326<h4>The Patterns and Smells 327</h4> 328<p>The patterns and smells are organized into "categories" that each 329 correspond to a single chapter in the book. The categories are accessible via 330 hyperlinks in the "All Categories" box on the left side. Once a category is 331 selected, the patterns within the category can be accessed from the "All 332 <i>categoryName</i>" box that appears below the "All Categories" box. 333</p> 334<p>The patterns and smells can also be accessed in the following ways: 335</p> 336<ul> 337<li>via hyperlinks from within the narratives 338</li> 339<li>via hyperlinks from other patterns or smells 340</li> 341<li>from the "Category Contents" sidebar on many pages 342</li> 343</ul> 344<p>The various categories can also be accessed from the <a href='Book Outline.html' class='Ref'>Book Outline</a>. 345</p><hr/> 346</td><hr/> 347<p><xmall> Page generated at Wed Feb 09 16:39:23 +1100 2011</small> 348</p> 349<p><small>
349 Copyright © 2003-2008 <a href="mailto:testautomationpatterns_at_gerardmeszaros.com">Gerard Meszaros</a> all rights reserved</small> 350</p></div> 351<div id='sidebarleft'> 352<div class='sidebarleft-block'> 353<table> 354<tr><td><b>All Categories</b></td> 355</tr> 356<tr> 357<td><a href='Introductory Narratives.html'>Introductory Narratives</a> 358</td> 359</tr> 360<tr> 361<td><a href='Web Site Instructions.html'>Web Site Instructions</a> 362</td> 363</tr> 364<tr> 365<td><a href='Code Refactorings.html'>Code Refactorings</a> 366</td> 367</tr> 368<tr> 369<td><a href='Database Patterns.html'>Database Patterns</a> 370</td> 371</tr> 372<tr> 373<td><a href='DfT Patterns.html'>DfT Patterns</a> 374</td> 375</tr> 376<tr> 377<td><a href='External Patterns.html'>External Patterns</a> 378</td> 379</tr> 380<tr> 381<td><a href='Fixture Setup Patterns.html'>Fixture Setup Patterns</a> 382</td> 383</tr> 384<tr> 385<td><a href='Fixture Teardown Patterns.html'>Fixture Teardown Patterns</a> 386</td> 387</tr> 388<tr> 389<td><a href='Front Matter.html'>Front Matter</a> 390</td> 391</tr> 392<tr> 393<td><a href='Glossary.html'>Glossary</a> 394</td> 395</tr> 396<tr> 397<td><a href='Misc.html'>Misc</a> 398</td> 399</tr> 400<tr> 401<td><a href='References.html'>References</a> 402</td> 403</tr> 404<tr> 405<td><a href='Result Verification Patterns.html'>Result Verification Patterns</a> 406</td> 407</tr> 408<tr> 409<td><a href='Sidebars.html'>Sidebars</a> 410</td> 411</tr> 412<tr> 413<td><a href='Terminology.html'>Terminology</a> 414</td> 415</tr> 416<tr> 417<td><a href='Test Double Patterns.html'>Test Double Patterns</a> 418</td> 419</tr> 420<tr> 421<td><a href='Test Organization.html'>Test Organization</a> 422</td> 423</tr> 424<tr> 425<td><a href='Test Refactorings.html'>Test Refactorings</a> 426</td> 427</tr> 428<tr> 429<td><a href='Test Smells.html'>Test Smells</a> 430</td> 431</tr> 432<tr> 433<td><a href='Test Strategy.html'>Test Strategy</a> 434</td> 435</tr> 436<tr> 437<td><a href='Tools.html'>Tools</a> 438</td> 439</tr> 440<tr> 441<td><a href='Value Patterns.html'>Value Patterns</a> 442</td> 443</tr> 444<tr> 445<td><a href='XUnit Basics.html'>XUnit Basics</a> 446</td> 447</tr> 448<tr> 449<td><a href='xUnit Members.html'>xUnit Members</a> 450</td> 451</tr> 452</table></div> 453<div class='sidebarleft-block'> 454<table> 455<tr><td><b>All "Web Site Instructions"</b></td> 456</tr> 457<tr> 458<td><a href='The Author.html'>About the Author</a> 459</td> 460</tr> 461<tr> 462<td><a href='Book Outline Diagrams.html'>Book Outline Diagrams</a> 463</td> 464</tr> 465<tr> 466<td><a href='Book Outline.html'>Book Outline</a> 467</td> 468</tr> 469<tr> 470<td><a href='ClearStream.html'>ClearStream Consulting</a> 471</td> 472</tr> 473<tr> 474<td><a href='course outline.html'>course outline</a> 475</td> 476</tr> 477<tr> 478<td><a href='Erratta.html'>Errata</a> 479</td> 480</tr> 481<tr> 482<td><a href='gerardmeszaros.html'>Gerard Meszaros</a> 483</td> 484</tr> 485<tr> 486<td><a href='gerards papers, classes and tutorial.html'>Gerard's Papers, Classes and Tutorials</a> 487</td> 488</tr> 489<tr> 490<td><a href='Gerards Presentations.html'>Gerard's Presentations</a> 491</td> 492</tr> 493<tr> 494<td><a href='Larger Cover.html'>Larger picture of cover</a> 495</td> 496</tr> 497<tr> 498<td><a href='register.html'>register</a> 499</td> 500</tr> 501<tr> 502<td><a href='training.html'>training</a> 503</td> 504</tr> 505<tr> 506<td><a href='index.html'>XUnit Test Patterns</a> 507</td> 508</tr> 509</table></div></div></body></html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.