<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>TDD</title>
        <link>http://geekswithblogs.net/rajeshpillai/category/10987.aspx</link>
        <description>TDD Notes, practices.</description>
        <language>en-US</language>
        <copyright>Rajesh Pillai</copyright>
        <managingEditor>thinkrajesh@yahoo.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>BDD using SpecFlow on ASP.NET MVC Application</title>
            <link>http://geekswithblogs.net/rajeshpillai/archive/2010/05/22/bdd-using-specflow-on-asp.net-mvc-application.aspx</link>
            <description>&lt;p&gt;I usually love doing TDD and am moving towards understanding BDD  (Behaviour Driven Development).  My learnings are documented in the form  of an article at CodeProject.&lt;/p&gt;
&lt;p&gt;The URL is  &lt;a href="http://www.codeproject.com/KB/architecture/BddWithSpecFlow.aspx"&gt;http://www.codeproject.com/KB/architecture/BddWithSpecFlow.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I  will keep this updated as and when I learn a couple of more things.&lt;/p&gt;
&lt;p&gt;Hope  you like it.&lt;/p&gt;
&lt;p&gt;Cheers !!!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/rajeshpillai/aggbug/140010.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rajesh Pillai</dc:creator>
            <guid>http://geekswithblogs.net/rajeshpillai/archive/2010/05/22/bdd-using-specflow-on-asp.net-mvc-application.aspx</guid>
            <pubDate>Sat, 22 May 2010 14:19:35 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/rajeshpillai/comments/140010.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/rajeshpillai/archive/2010/05/22/bdd-using-specflow-on-asp.net-mvc-application.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/rajeshpillai/comments/commentRss/140010.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/rajeshpillai/services/trackbacks/140010.aspx</trackback:ping>
        </item>
        <item>
            <title>Summary of MVP in Action - Unit Testing</title>
            <link>http://geekswithblogs.net/rajeshpillai/archive/2009/11/30/mvpinactiontdd.aspx</link>
            <description>&lt;h2&gt;MVP in Action - Unit Test&lt;/h2&gt;
&lt;p&gt;Read the post here..&lt;a href="http://geekswithblogs.net/rajeshpillai/archive/2009/11/30/mvp2.aspx"&gt;geekswithblogs.net/rajeshpillai/archive/2009/11/30/mvp2.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Synopsis&lt;br /&gt;
&lt;br /&gt;
This is in continuation to the article &lt;a href="http://geekswithblogs.net/rajeshpillai/archive/2009/11/29/mvp1.aspx"&gt;geekswithblogs.net/rajeshpillai/archive/2009/11/29/mvp1.aspx&lt;/a&gt;.  This post will deal with &lt;br /&gt;
writing simple unit test case for the "User" user creation use case we covered in the above blog post.&lt;/p&gt;
&lt;p&gt;Background&lt;/p&gt;
&lt;p&gt;Unit testing means testing a piece of code or a method.  White unit testing we need to stub or fake out external dependencies&lt;br /&gt;
so that the test can run in isolation.  The following two test cases we will cover&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;When saving a user with valid data should display "Successfully submitted the user." message on the view.&lt;/li&gt;
    &lt;li&gt;When saving a user with empty name should display "&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;user:User name cannot be empty&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;" the &lt;br /&gt;
    following message on the view.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Read the post here..&lt;a href="http://geekswithblogs.net/rajeshpillai/archive/2009/11/30/mvp2.aspx"&gt;geekswithblogs.net/rajeshpillai/archive/2009/11/30/mvp2.aspx&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/rajeshpillai/aggbug/136617.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rajesh Pillai</dc:creator>
            <guid>http://geekswithblogs.net/rajeshpillai/archive/2009/11/30/mvpinactiontdd.aspx</guid>
            <pubDate>Mon, 30 Nov 2009 12:01:08 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/rajeshpillai/comments/136617.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/rajeshpillai/archive/2009/11/30/mvpinactiontdd.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/rajeshpillai/comments/commentRss/136617.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/rajeshpillai/services/trackbacks/136617.aspx</trackback:ping>
        </item>
        <item>
            <title>Some notes from my tdd session</title>
            <link>http://geekswithblogs.net/rajeshpillai/archive/2009/11/28/some-notes-from-my-tdd-session.aspx</link>
            <description>&lt;p&gt;Here's a quick notes from the TDD session which I conducted some time back.&lt;/p&gt;
&lt;h1&gt;Introduction&lt;/h1&gt;
&lt;ul&gt;
    &lt;li&gt;Writing test before writing production code.&lt;/li&gt;
    &lt;li&gt;Design as you go along.&lt;/li&gt;
    &lt;li&gt;Follow Red-Green-Refactor paradigm&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Benefits&lt;/h1&gt;
&lt;ul&gt;
    &lt;li&gt;Spot design flow early.&lt;/li&gt;
    &lt;li&gt;Test before the production code is built.&lt;/li&gt;
    &lt;li&gt;Identify poort requirements or requirement gaps.&lt;/li&gt;
    &lt;li&gt;Reduced testing time.&lt;/li&gt;
    &lt;li&gt;The test forms the functional document for your code.&lt;/li&gt;
    &lt;li&gt;Quickly identify bugs.&lt;/li&gt;
    &lt;li&gt;Reduces the cost of bugs in the long run.&lt;/li&gt;
    &lt;li&gt;Low level regression test suite.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Road blocks to TDD&lt;/h1&gt;
&lt;p&gt;When doing TDD the following road blocks you may hit.&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Real objects are slow&lt;/li&gt;
    &lt;li&gt;Ral objecs are difficult to mock.&lt;/li&gt;
    &lt;li&gt;Rad object may be unavailable.&lt;/li&gt;
    &lt;li&gt;Real object may be costly.&lt;/li&gt;
    &lt;li&gt;Real object does not yet exits.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here "Real Object" is the object under test.&lt;/p&gt;
&lt;h1&gt;The solution - Enter Mocking&lt;/h1&gt;
&lt;ul&gt;
    &lt;li&gt;What is a mock object?
    &lt;ul&gt;
        &lt;li&gt;Mock objects are stand-in-object for real object.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;Use of mock object
    &lt;ul&gt;
        &lt;li&gt;Real object has non-deterministic behaviour.&lt;/li&gt;
        &lt;li&gt;Real object is slow.&lt;/li&gt;
        &lt;li&gt;Real object is difficult to setup.&lt;/li&gt;
        &lt;li&gt;Real object is expensive.&lt;br /&gt;
         &lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Rhino Mock (The mocking framework)&lt;/h1&gt;
&lt;ul&gt;
    &lt;li&gt;A dynamic mock object framework for the .NET platform.&lt;/li&gt;
    &lt;li&gt;Objective is to ease testing by allowing the developer to create mock implementation of custom&lt;br /&gt;
    objects and verify the interactions using unit testing.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Stubs and Mocks&lt;/h1&gt;
&lt;ul&gt;
    &lt;li&gt;A mock is an object that we can set expectations on, and which will verify that the expected actions have&lt;br /&gt;
    indeed occurred.&lt;/li&gt;
    &lt;li&gt;A stub is an object that you use in order to pass to the code under test.  You can setup expectations on it, &lt;br /&gt;
    so it would act in certain ways, but those expectations will never be verified.  A stub's properties will &lt;br /&gt;
    automatically behave like normal properties and you cann't set expectations on them.&lt;/li&gt;
    &lt;li&gt;If you want to verify the behaviour of the code under test, you wil use a mock with the appropriate &lt;br /&gt;
    expectation and verify that.  I you want to just pass a value that may need to act in  a certain way, but isn't the&lt;br /&gt;
    focus of the test you will use a stub.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;u&gt;IMPORTANT: A stub will never cause a test to fail.&lt;/u&gt;&lt;/p&gt;
&lt;h1&gt;Rhino Mocks - 1&lt;/h1&gt;
&lt;ul&gt;
    &lt;li&gt;CreateMock / StrickMock
    &lt;ul&gt;
        &lt;li&gt;For strict mockign&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;DynamicMock
    &lt;ul&gt;
        &lt;li&gt;Flexible&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;PartialMock
    &lt;ul&gt;
        &lt;li&gt;Mock concrete class&lt;/li&gt;
        &lt;li&gt;Only  mock virtual methods&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;AAA approach&lt;/h1&gt;
&lt;ul&gt;
    &lt;li&gt;A - Arrange
    &lt;ul&gt;
        &lt;li&gt;Arrange your tests.  Setup your values.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;A - Act/action
    &lt;ul&gt;
        &lt;li&gt;Execute the testing condition.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;A - Assert
    &lt;ul&gt;
        &lt;li&gt;Assert on expectations.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Happy TDD'ing....&lt;/p&gt;
&lt;br /&gt; &lt;img src="http://geekswithblogs.net/rajeshpillai/aggbug/136594.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Rajesh Pillai</dc:creator>
            <guid>http://geekswithblogs.net/rajeshpillai/archive/2009/11/28/some-notes-from-my-tdd-session.aspx</guid>
            <pubDate>Sat, 28 Nov 2009 11:17:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/rajeshpillai/comments/136594.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/rajeshpillai/archive/2009/11/28/some-notes-from-my-tdd-session.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/rajeshpillai/comments/commentRss/136594.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/rajeshpillai/services/trackbacks/136594.aspx</trackback:ping>
        </item>
    </channel>
</rss>
