<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx</link><description>In OO there&amp;#39;s levels of abstraction. A class, for example, abstracts a read-world concept into a encapsulated bit of code. A class is autonomous. That class lives in world with other classes and interacts with them, but is autonomous. I believe development</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Mind Gravy  &amp;raquo; Blog Archive   &amp;raquo; links for 2008-04-02</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1567144</link><pubDate>Wed, 02 Apr 2008 12:36:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1567144</guid><dc:creator>Mind Gravy  » Blog Archive   » links for 2008-04-02</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Mind Gravy &amp;nbsp;&amp;amp;raquo; Blog Archive &amp;nbsp; &amp;amp;raquo; links for 2008-04-02&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1567144" width="1" height="1"&gt;</description></item><item><title>re: Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1515463</link><pubDate>Fri, 15 Feb 2008 22:17:55 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1515463</guid><dc:creator>tobsen</dc:creator><description>&lt;p&gt;@andrew: sure, test the granular parts as well. But your user story can be tested also, without the other parts. I like to use mock objects to really test the flow of a class (e.g. the presenter) and to seperate the it from the implementation of other classes. SO it doesn&amp;#39;t matter if SaveRegistrationData is really saving thinmgs as long as the presenter calls it. That imho is &amp;quot;testing the behaviour&amp;quot;. Imo the wiki article is no quite right. I consider &amp;quot;calculating the correct value&amp;quot; a functionality (Unittest) - not a behaviour... &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1515463" width="1" height="1"&gt;</description></item><item><title>re: Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1515198</link><pubDate>Fri, 15 Feb 2008 14:44:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1515198</guid><dc:creator>PeterRitchie</dc:creator><description>&lt;p&gt;@sanj: I agree. &amp;nbsp;I hope I didn't come across as being anti-TDD or anti-BDD. &amp;nbsp;My intention was to try to point out that using one of (TDD, BDD, Unit Testing) should not preclude all the others. &amp;nbsp;I believe that they all should be part of your dev testing repertoire. &amp;nbsp;Thinking TDD is all you need to do is not a good thing. &amp;nbsp;Doing just TDD is better than no dev testing...&lt;/p&gt;
&lt;p&gt;Do BDD and TDD then follow up and unit test what you now know is needed/used. &amp;nbsp;I don't think user stores should be concerned with implementation-specific cases; but things like boundary cases should be included in dev testing.&lt;/p&gt;
&lt;p&gt;You start to dilute TDD and BDD if you couple implementation details into it; decouple that into a separate unit testing effort.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1515198" width="1" height="1"&gt;</description></item><item><title>re: Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1515084</link><pubDate>Fri, 15 Feb 2008 10:33:53 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1515084</guid><dc:creator>andrew myhre</dc:creator><description>&lt;p&gt;I agree, I feel more comfortable testing individual class methods and then building behaviour tests which could link several classes into a process.&lt;/p&gt;
&lt;p&gt;e.g: Given the user story &amp;#39;User must activate their account before they can login&amp;#39;, I would need to write a test which includes my membership class, email class, database class etc in order to test the entire process. I would write those tests after I&amp;#39;ve tested the granular parts (e.g: Save Registration Data).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1515084" width="1" height="1"&gt;</description></item><item><title>re: Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1514646</link><pubDate>Thu, 14 Feb 2008 22:44:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1514646</guid><dc:creator>Troy DeMonbreun</dc:creator><description>&lt;p&gt;My take:&lt;/p&gt;
&lt;p&gt;&amp;lt;a href=&amp;quot;&lt;a rel="nofollow" target="_new" href="http://blog.troyd.net/Test+Supported+Development+TSD+Is+NOT+Test+Driven+Development+TDD.aspx&amp;quot;&amp;gt;Test"&gt;blog.troyd.net/Test+Supported+Development+TSD+Is+NOT+Test+Driven+Development+TDD.aspx&amp;quot;&amp;gt;Test&lt;/a&gt; Supported Development (TSD) is NOT Test Driven Development (TDD)&amp;lt;/a&amp;gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1514646" width="1" height="1"&gt;</description></item><item><title>re: Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1514644</link><pubDate>Thu, 14 Feb 2008 22:41:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1514644</guid><dc:creator>sanj</dc:creator><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;TDD/BDD is part of the agile tool set. In order to be &amp;quot;agile&amp;quot; you only drive out code that you &amp;quot;need&amp;quot; as opposed to writing abstractions that model every conceivable detail. You only extend the abstraction when your stories dictate it, thereby helping you focus on functionality that is currently necessary and not &amp;quot;perceived&amp;quot; in the &amp;quot;future&amp;quot;. From experience this is a good thing. By only creating what you currently need you prevent yourself from over engineering solutions and creating code that will most probably be scrapped when the customer changes his mind. It keeps you agile.&lt;/p&gt;
&lt;p&gt;You may use interaction or state-based testing depending on the situation. You are not tied to interaction-based testing.&lt;/p&gt;
&lt;p&gt;Granted that vanilla unit tests don&amp;#39;t tests all scenarios. One reason for this is that unit tests need to execute in a very short time. If we ran test for all the scenarios, say the 4,294,967,296 possibilities in the EratosthenesPrimesCalculator - then our unit tests may never finish running by the end of the day. The longer it takes for something to run the less liked we are to run them. I do agree that unless we test all 4,294,967,296 possibilities that we are not sure that the code works. So we might use a tool like ScalaCheck (&lt;a href="http://code.google.com/p/scalacheck/" target="_new" rel="nofollow"&gt;code.google.com/.../scalacheck&lt;/a&gt;)(if it existed in Java) to test all these possibilities. These could be run as &amp;nbsp;integration test, as we don&amp;#39;t run integration tests repeatedly in the TDD/BDD cycle of write a failing test, get it to pass and refactor. So essentially the &amp;quot;unit&amp;quot; tests need to be fast and lightweight and should test boundary cases and some probable inputs and expected outputs. Integration tests or acceptances tests could test all possibilities.&lt;/p&gt;
&lt;p&gt;Although user stories don&amp;#39;t cover &amp;quot;implementation details like the limits of the &amp;quot;int&amp;quot; type (or &amp;quot;Integer&amp;quot; type in Java) isn&amp;#39;t a concern of the users&amp;quot; we as developers should. We know the development platform and it is our duty to verify any assumptions made by the customer on the story cards. In an agile environment you should have access to a &amp;quot;customer&amp;quot; so any of these constraints should be made known to the customer so any changes can be made. (Maybe 4,294,967,296 is unnecessary or too little for the scenario)&lt;/p&gt;
&lt;p&gt;TDD/BDD are design tools as people have generally commented. But I do think we have a testing/speccing mindset while using these frameworks and therefore boundary cases and the &amp;nbsp;like have to be tested/specced because it leads to a better design. (eg. What happens when a null is passed into a method? &amp;nbsp;A good design would handle this although it is not on the story card)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1514644" width="1" height="1"&gt;</description></item><item><title>Unit Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1514640</link><pubDate>Thu, 14 Feb 2008 22:35:30 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1514640</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You&amp;#39;ve been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1514640" width="1" height="1"&gt;</description></item><item><title>re: Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1514575</link><pubDate>Thu, 14 Feb 2008 20:57:04 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1514575</guid><dc:creator>PeterRitchie</dc:creator><description>&lt;p&gt;Using a test-first approach, you first write a test for a method before you write the method. &amp;nbsp;You only know conceptually how that method is going to be used in a user story (e.g. from TDD By Example, testMultiplication, which tests only that a particular multiplication with one value succeeded). &amp;nbsp;Yes, your specific scenarios could be boundary cases; but one: that's not usually what user stories describe, you're usually testing interactions; two: implementation details like the limits of the &amp;quot;int&amp;quot; type (or &amp;quot;Integer&amp;quot; type in Java) isn't a concern of the users; and three: it couples implementation details to the user stories (requirements artifacts).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1514575" width="1" height="1"&gt;</description></item><item><title>re: Testing the Units</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/02/06/unit-testing-the-units.aspx#1514535</link><pubDate>Thu, 14 Feb 2008 20:00:36 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1514535</guid><dc:creator>edovale</dc:creator><description>&lt;p&gt;I fail to see how not testing for boundary cases is in any way related to TDD or BDD.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1514535" width="1" height="1"&gt;</description></item></channel></rss>