<?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/"
	>

<channel>
	<title>the tar pit &#187; todd</title>
	<atom:link href="http://blog.goneopen.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.goneopen.com</link>
	<description>Thrashing around in the stickiness of software</description>
	<lastBuildDate>Wed, 25 Aug 2010 10:10:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>storyq-vs-slim-fitnesse</title>
		<link>http://blog.goneopen.com/2010/08/storyq-vs-slim-fitnesse/</link>
		<comments>http://blog.goneopen.com/2010/08/storyq-vs-slim-fitnesse/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 10:08:25 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/storyq-vs-slim-fitnesse/</guid>
		<description><![CDATA[Acceptance testing from user stories via StoryQ and Slim Recently I was working with a team using user stories for acceptance testing (in .Net). As it turned out I had the opportunity to implement the acceptance tests in both Slim/fitnesse and StoryQ. To me, either framework is fine because they are both the same strategy: [...]]]></description>
			<content:encoded><![CDATA[<h2>Acceptance testing from user stories via StoryQ and Slim</h2>

<p>Recently I was working with a team using user stories for acceptance testing (in .Net). As it turned out I had the opportunity to implement the acceptance tests in both Slim/fitnesse and StoryQ. To me, either framework is fine because they are both the same strategy: they create an abstraction that is understood by the customer that we can run against the system under test. Below is an extract of the user story that was discussed with the customer (and there was also a sketch of the <span class="caps">GUI </span>that I haven&#8217;t included) and what I&#8217;ll show is the StoryQ and Slim implementations up to the point of hooking into the system under test (SUT). The process for each is pretty similar of a two set process: (1) code up the test as the customer representation (2) create (C#) code that wraps hooking into the <span class="caps">SUT</span></p>



<pre>    
                  step one           step two
 ------------------------------------------------
  user story  -&gt;  xUnit StoryQ    -&gt; TestUniverse
  user story  -&gt;  story test wiki -&gt; Fixtures
</pre>



<h2>User story</h2>

<p>This story was written in plain and developed over three cycles over the course of an hour. There was actually about 7 scenarios in the end.</p>



<pre>
As a Account Manager
I want to cater for risks terminated in System1 after extraction to System2
So that I offer a renewal to the Broker

    Given I have a policy                                                                                                                                        
      And it has a current risk in System2                                                                                                                           
    When the risk is terminated in System1                                                                                                                        
    Then the risk is deleted in System2                    

    Given I have a policy                                                                                                                                      
    When a deleted risk later than the load date is added                                                                                                    
    Then it should be rerated      
                                                                                                                      
    Given I have a policy                                                                                                                                        
      And it has an current risk in System2                                                                                                                          
    When its status is ready to review                                                                                                                           
      And a risk is deleted in System1                                                                                                                            
    Then the policy should be rated                                                                                                                              
      And the policy should remain in the same status        
</pre>



<h2>Example One: StoryQ</h2>

<p>I took this user story and then converted it into StoryQ using the StoryQ converter that you can get with the library. StoryQ has a slight difference: (a) it uses the <code>In order</code> syntax and (b) I had to have a <code>Scenario</code> with each <code>Given/When/Then</code>. It took me in total about half an hour to download, add as a reference and convert the story.</p>

<h3>Story to storyq via converter</h3>

<p>When doing the conversion, the converter will error until it is in the correct format. Here&#8217;s what I had to rewrite to:</p>



<pre>
Story is Terminated risks after extractions
  In order to offer renewal to the Broker
  As a Account Manager
  I want to cater for risks terminated in System1 after extraction to System2

 With scenario risks become deleted in System2
   Given I have a policy                                                                                                                                        
     And it has a current risk in System2                                                                                                                           
  When the risk is terminated in System1                                                                                                                        
    Then the risk is deleted in System2                    

 With scenario newly deleted risks need to be rerated
   Given I have a policy                                                                                                                                      
   When a deleted risk later than the load date is added                                                                                                    
   Then it should be rerated      

 With scenario status being reviewed
   Given I have a policy                                                                                                                                        
     And it has an current risk in System2                                                                                                                          
   When its status is ready to review                                                                                                                           
     And a risk is deleted in System1                                                                                                                            
   Then the policy should be rated                                                                                                                              
     And the policy should remain in the same status            
</pre>

<p>  </p>

<p>The output of the converter in C# is:</p>



<pre class="brush: csharp;">
new Story(&quot;Terminated risks after extractions&quot;)
       .InOrderTo(&quot;offer renewal to the Broker&quot;)
       .AsA(&quot;Account Manager&quot;)
       .IWant(&quot;to cater for risks terminated in System1 after extraction to System2&quot;)

       .WithScenario(&quot;risks become deleted in System2&quot;)
       .Given(&quot;I have a policy&quot;)
       .And(&quot;it has a current risk in System2&quot;)
       .When(&quot;the risk is terminated in System1&quot;)
       .Then(&quot;the risk is deleted in System2&quot;)

       .WithScenario(&quot;newly deleted risks need to be rerated&quot;)
       .Given(&quot;I have a policy&quot;)
       .When(&quot;a deleted risk later than the load date is added&quot;)
       .Then(&quot;it should be rerated&quot;)

       .WithScenario(&quot;status being reviewed&quot;)
       .Given(&quot;I have a policy&quot;)
       .And(&quot;it has an current risk in System2&quot;)
       .When(&quot;its status is ready to review&quot;)
       .And(&quot;a risk is deleted in System1&quot;)
       .Then(&quot;the policy should be rated&quot;)
       .And(&quot;the policy should remain in the same status&quot;)
</pre>



<h3>StoryQ into xUnit</h3>

<p>From this output you add it into a xUnit test framework &#8211; so far either <span class="caps">MST</span>est or NUnit. We were using <span class="caps">MST</span>est and it looks like this. We need to add</p>


<ul>
<li>Testclass, Testmethod as per <span class="caps">MST</span>est</li>
<li>I add indentation myself</li>
<li><code>.ExecuteWithReport(MethodBase.GetCurrentMethod())</code> at the end</li>
</ul>





<pre class="brush: csharp;">
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using StoryQ;

namespace Tests.System.Acceptance
{
    [TestClass]
    public class TerminatedRiskAfterExtractionTest
    {
        [TestMethod]
        public void Extraction()
        {
            new Story(&quot;Terminated risks after extractions&quot;)
                .InOrderTo(&quot;offer renewal to the Broker&quot;)
                .AsA(&quot;Account Manager&quot;)
                .IWant(&quot;to cater for risks terminated in System1 after extraction to System2&quot;)

                .WithScenario(&quot;risks become deleted in System2&quot;)
                    .Given(&quot;I have a policy&quot;)
                        .And(&quot;it has a current risk in System2&quot;)
                    .When(&quot;the risk is terminated in System1&quot;)
                    .Then(&quot;the risk is deleted in System2&quot;)

                .WithScenario(&quot;newly deleted risks need to be rerated&quot;)
                    .Given(&quot;I have a policy&quot;)
                    .When(&quot;a deleted risk later than the load date is added&quot;)
                    .Then(&quot;it should be rerated&quot;)

               .WithScenario(&quot;status being reviewed&quot;)
                   .Given(&quot;I have a policy&quot;)
                       .And(&quot;it has an current risk in System2&quot;)
                   .When(&quot;its status is ready to review&quot;)
                       .And(&quot;a risk is deleted in System1&quot;)
                   .Then(&quot;the policy should be rated&quot;)
                       .And(&quot;the policy should remain in the same status&quot;)

                .ExecuteWithReport(MethodBase.GetCurrentMethod());
        }
    }
}
</pre>



<h3>Link to the <span class="caps">SUT </span>(TestUniverse)</h3>

<p>StoryQ needs to link the user story test text to the <span class="caps">SUT.</span> One clean approach is to use a TestUniverse &#8211; and as you will see it replicates the idea of the fitnesse fixture. A quick summary as you look at the code:</p>


<ul>
<li>add a class TestUniverse, have a reference to it available (<code>_t_</code>) and instatiate it in the <code>Setup()</code> </li>
<li>convert string text to methods eg (<code>&quot;I have a policy&quot;</code> to <code>_t.IHaveAPolicy</code>)</li>
<li>add methods to the TestUniverse (personally I use resharper and it does the work for me)</li>
<li>quite quickly you get reuse patterns eg (<code>_t.IHaveAPolicy</code>)</li>
<li>I tend to create methods only as I need them because it gives me a better sense of tests actually implemented </li>
</ul>





<pre class="brush: csharp;">
    using System.Reflection;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using StoryQ;

    namespace Tests.System.Acceptance
    {
        [TestClass]
        public class TerminatedRiskInSystem1AfterExtractionTest
        {
            private TestUniverse _t;

            [TestInitialize]
            public void Setup()
            {
                _t = new TestUniverse();
            }

            [TestMethod]
            public void Extraction()
            {
                new Story(&quot;Terminated risks after extractions&quot;)
                    .InOrderTo(&quot;offer renewal to the Broker&quot;)
                    .AsA(&quot;Account Manager&quot;)
                    .IWant(&quot;to cater for risks terminated in System1 after extraction to System2&quot;)

                    .WithScenario(&quot;risks become deleted in System2&quot;)
                    .Given(_t.IHaveAPolicy)
                        .And(&quot;it has a current risk in System2&quot;)
                    .When(&quot;the risk is terminated in System1&quot;)
                    .Then(&quot;the risk is deleted in System2&quot;)

                    .WithScenario(&quot;newly deleted risks need to be rerated&quot;)
                    .Given(_t.IHaveAPolicy)
                    .When(&quot;a deleted risk later than the load date is added&quot;)
                    .Then(&quot;the policy should be rerated&quot;)

                    .WithScenario(&quot;status being reviewed&quot;)
                    .Given(_t.IHaveAPolicy)
                        .And(&quot;it has an current risk in System2&quot;)
                    .When(_t.ItsStatusIsReadyToReview)
                        .And(&quot;a risk is deleted in System1&quot;)
                    .Then(&quot;the policy should be rated&quot;)
                        .And(&quot;the policy should remain in the same status&quot;)

                    .ExecuteWithReport(MethodBase.GetCurrentMethod());
            }

        }

        public class TestUniverse
        {
            // private variables here if needed

            public void IHaveAPolicy()
            {
                // Hook up to SUT
            }

            public void ItsStatusIsReadyToReview()
            {
                // Hook up to SUT
            }

            public void ThePolicyShouldBeReRated()
            {
                // Hook up to SUT
                // Assertions too
            }

        }
    }   
</pre>



<p>Hopefully, you can see the TestUniverse helps us keep the two parts of the test separated &#8211; and of course, you could have them in separate files if you really wanted.</p>

<p>Now when you run this test through your favourite xUnit runner (MSTest, Resharper, TestDriven.Net, Gallio) you will get the results of the test. Or more appropriately, I have the tests ready and waiting. Now we implement the system before return to these after to hook up. Yes, I confess, these system tests are test-last! I explain that somewhere else.</p>

<h2>Example Two: Slim</h2>

<p>Having got the code in StoryQ to this point, we decided to investigate what the same user story would look like in Slim. This exercise turned out to take somewhat longer. In C#, there are no specific libraries for implementing the <code>Given/When/Then</code> although there is one in java (givenWenZen). So we given our stories we implemented them using a <code>Script table</code>. This turned out to the fruitful.</p>

<h3>Slim story test wiki</h3>

<p>Here are the wiki tables. In the actual, wiki we also included the original user story around the table which for this example I have included only the scenario.</p>



<pre>
With scenario risks become deleted in System2

|script|Risk Terminated                  |
|check |I have a policy                 ||
|check |it has a current risk in System2||
|terminate risk                          |
|ensure|risk is deleted                  |

With scenario newly deleted risks need to be rerated

|script|Risk Terminated                                |
|check |I have a policy                               ||
|check |deleted risk later than the load date is added||
|ensure|risk is rerated                                |

With scenario status being reviewed       

|script|Risk Terminated                                        |
|check |I have a policy                        |               |
|check |it has a current risk in System2       |               |
|check |status is in                           |ready to review|
|check |risk is deleted                        |               |
|ensure|policy is rerated                                      |
|check |policy should remain in the same status|ready to review|
</pre>

<p>  </p>

<p>My working knowledge of the <code>check, ensure, reject</code> took a while to get up to speed including the mechanism for reporting back values in empty cells (eg <code>|check|I have a policy||</code>). Other than that it took as about an hour to get on top of structure for the table in this case. Script table has worked okay but it did mean that we went from a user story to a story test that in the future we should go straight to. Having said that the user story Given/When/Then is nice for its natural language syntax and helps avoids sticking solely to <span class="caps">GUI</span>-type actions.</p>

<h3>Slim fixture</h3>

<p>The slim fixture is pretty straight forward. We hardcoded in our policy and risk to start with. Later on we would swap this out for the system.</p>



<pre class="brush: csharp;">
namespace Tests.System.Acceptance
{
    public class RiskTerminated
    {

        public string IHaveAPolicy()
        {
            return &quot;12-4567846-POF&quot;;
        }

        public string ItHasACurrentRiskInSystem2()
        {
            return &quot;001&quot;;
        }

        public bool terminateRisk()
        {
            return true;
        }

        public bool riskIsDeleted()
        {
            return true;
        }

        public string deletedRiskLaterThanTheLoadDateIsAdded()
        {
            return string.Empty;
        }

        public bool RiskIsRerated()
        {
            return true;
        }

        public bool PolicyIsRerated()
        {
            return true;
        }

        public string statusisin()
        {
            return string.Empty;
        }

        public string policyShouldRemainInTheSameStatus()
        {
            return string.Empty;
        }

        public bool getAListOfCancelledRisksFromSystem1()
        {
            return true;
        }

        public bool theRiskIsNotAvailableInSystem2()
        {
            return true;
        }
    }
}
</pre>



<p>Now that this is all working we can run the tests in Fitnesse. We already had Fitnesse up and running with Slim build to the correct version. Don&#8217;t underestimate the time and expertise needed to get this all up and running &#8211; it&#8217;s not hard, after the first time that is! We could have also got our wiki running under a <code>Generic Test</code> in Visual Studio but we haven&#8217;t gone that far yet.</p>

<h2>Some general comments</h2>

<p>If you were attentive to the style of tests, you might have noticed that we passed in no values for the tests. In this testing, the setup is limited to fetching existing data and then making changes from there. Because we are interested in knowing which pieces of data were touched the tests do want, in this case, the policies reported back. This is not ideal but pragmatic for the state of the system. Both StoryQ and Slim can report back this type of information &#8211; in these examples, Slim has this implemented  but not StoryQ.</p>


<ul>
<li>StoryQ has the least barrier to entry and keeps the tests focussed at the developers</li>
<li>StoryQ is easy to get onto a build server</li>
<li>StoryQ has much better for refactoring because it is in C# in an <span class="caps">IDE </span>and is not using (magic) string matching &#8211; you could though</li>
<li>StoryQ is generally unknown and is harder to introduce particularly to devs that haven&#8217;t really grasped Fitnesse</li>
<li>Cucumber could just as easily be used (I just thought that I would throw that in from left field)</li>
<li>Given/When/Then may be limited as a rubric for testing &#8211; but those constraints are also benefits</li>
<li>Slim allows realistically allows more comments around tests</li>
<li>Wiki reporting is potentially richer and closer to the customer</li>
<li>Separate systems of a wiki and code is good separation</li>
<li>The wiki and code are nonetheless two different systems &#8211; that comes at a cost</li>
<li>If the wiki isn&#8217;t driving development then I&#8217;m not convinced it is cost effective</li>
<li>Slim required more knowledge around which table to use and its constraints &#8211; that&#8217;s (sort of) a one-time cost</li>
<li>I wouldn&#8217;t mind a Given/When/Then table for Slim &#8211; apparently UncleBob might be writing one?</li>
</ul>



<h2>Rock on having customers</h2>

<p>A final note in this example. I most interested in the benefits of this type of testing rather than the specific implementation. Anything that allows us to have more conversations with our code base and the people who develop it the better. By writing the user stories down before development means we need to do the &#8220;outside in&#8221; thing first. By coming back to them, I have found that it flushes assumptions made in development and makes us remember our earlier discussions. It easy to forget that our customers are often good at helping us create abstractions in our code base that we loose sight of in the middle coding the solution. Those abstractions live in the user stories &#8211; to hook up the user stories to the <span class="caps">SUT </span>we often need to decouple our code in ways that is not required when our only client code of the <span class="caps">SUT </span>is the application/UI. So I say rock on having customers that require us to have proxies in the form of code to represent them!</p>

<p><pre class="brush: csharp;">[/sourcecode]</pre></p>]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/storyq-vs-slim-fitnesse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>test-automation-pyramid-and-webservices</title>
		<link>http://blog.goneopen.com/2010/08/test-automation-pyramid-and-webservices/</link>
		<comments>http://blog.goneopen.com/2010/08/test-automation-pyramid-and-webservices/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 09:43:07 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[test automation pyramid]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/test-automation-pyramid-and-webservices/</guid>
		<description><![CDATA[Using web services is easy. That is if we listen to vendors. Point to a wsdl and hey presto easy data integration. Rarely is it that easy for professional programmers. We have to be able to get through to endpoints via proxies, use credentials and construct the payloads correctly and all this across different environments. [...]]]></description>
			<content:encoded><![CDATA[<p>Using web services is easy. That is if we listen to vendors. Point to a wsdl and hey presto easy data integration. Rarely is it that easy for professional programmers. We have to be able to get through to endpoints via proxies, use credentials and construct the payloads correctly and all this across different environments. Add the dominance of point-and-click <span class="caps">WSDL </span>integration, many developers I talk to do really work at the code level for these types of integration points or if they do it is to the extent of passive code generators. So to suggest <span class="caps">TDD </span>on web services is, at best, perplexing. Here I am trying to explain how the test automation pyramid helps how to <span class="caps">TDD </span>web services. </p>

<h2>Test-first web services?</h2>

<p>Can we do test-first development on web services? or is test-first webservices an oxymoron? (ok, assume each is only one word <img src='http://blog.goneopen.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ) My simple answer is no. But the more complex answer is that you have to accept some conditions to make it worthwhile. These conditions to me are important concepts that lead to do test-first rather than the other way around. </p>

<p>One condition is that my own domain concepts remain clean. To keep it clean this means I keep the domain from the web service from being within my domain. For example, if you have a look at the samples demonstrating how to use a web service the service proxy and the domain is right there in the application &#8211; so for web application, you&#8217;ll see references in the code behind. This worries me. When the web service changes and the code is auto generated this new code is likely then to be littered throughout that code. Another related condition is that integration points should come through my infrastructure layer because it aids testability. So, if I can get at the service reference directly I am in most cases going to have an ad hoc error handling, logging and domain mapping strategy.</p>

<p>Another condition is that there is an impedance mismatch between our domain the service domain. We should deal with this mismatch as early as possible and as regularly as possible. We also should deal with these issues test-first and in isolation from the rest of the code. In practice, this is a mapper concern and we have vast array of options (eg automapper library, <span class="caps">LINQ</span>). These options are likely to depend on the complexity of the mapping. For example, if we use <span class="caps">WSE3 </span>bindings then we will be mapping from a <span class="caps">XML </span>structure into an object. Here we&#8217;ll most likely do the heavy lifting with a <span class="caps">XML </span>parser such as <code>System.Linq.Xml</code>. Alternatively, if we are using the ServiceModel bindings then we will be mapping object to object. If these models follow similar conventions we might get away with automapper and if not we are likely to roll our own. I would suggest if you are rolling your own that the interface of automapper might be nice to follow though (eg <code>Mapper.Map&lt;T, T1&gt;(data)</code>).</p>

<p>I think there is a simple rule of thumb with mapping domains: you can either deal with the complexity now or later. But, regardless, you&#8217;ll have to deal with the intricacies at some point. Test-first demands that you deal with them one-at-a-time and now. Alternatively, you delay and you&#8217;ll have to deal with at integration time and this often means that someone else is finding them &#8211; and in its worst case, it is in production! I am always surprised that how many &#8220;rules&#8221; there are when mapping domains and also how much we can actually do before we try to integrate. I was just working with a developer who has done a lot of this type of integration work but never test-first. As we proceeded test-first, she starting reflecting on how much of this mapping work that she usually did under test conditions could be moved forward into the development. On finishing that piece of work we also we surprised how many tests were required to do the mapping &#8211; a rough count was 150 individual tests across 20 test classes. This was for mapping two similar domains each with 5 domain models. </p>

<h2>What code do you really need to write?</h2>

<p>So let&#8217;s say that you accept that you don&#8217;t want to have a direct reference to the client proxy, what else it is needed? Of course, the answer is it depends. It depends on:</p>


<ul>
<li><strong>client proxy generated</strong> (eg <span class="caps">WSE3 </span>vs ServiceModel): when using the client proxy the <span class="caps">WSE3 </span>will require a little more inline work around, say, <code>Proxy</code>, <code>SetClientCredential</code> methods whereas the ServiceModel can have it inline or be delegated to the configuration file</li>
<li><strong>configuration model</strong> (eg xml (app.config) vs fluent configuration (programatic)): you may want to deal with configuration through a fluent configuration regardless of an app.config. This is useful for configuration checking and logging within environments. Personally, the more self checking you now for configuration settings the easier code will be to deploy through the environments. Leaving configuration checking and setting to solely to operations people is good example of throwing code over the fence. Configuration becomes someone else&#8217;s problem.</li>
<li><strong>reference data passed with each request</strong>: Most systems require some form reference data that exists with each and every request. I prefer to avoid handling that at the per request level but rather when service instantiating. This information is less likely to the credential information.</li>
<li><strong>security headers</strong>: you may need to add security headers to your payload. I forget which WS* standard this relates to but it is a strategy just like proxies and credentials that needs to be catered for. <span class="caps">WSE3 </span>and ServiceModel each have their own mechanisms to do this.</li>
<li><strong>complexity of domain mappings</strong>: you will need to call the mapping concern to do this work but should only be a one-liner because you have designed and tested this somewhere else. It is worth noting the extent of difference though. With simple pass through calls some mappings are almost a simple value. Take for example, a calculation service upon return may be a simple value. However, with domain synching the domain mapping are somewhat a complex set of rules to get the service to accept your data. Actually, I often  </li>
<li><strong>error handling strategy</strong>: we are likely to want to catch exceptions and throw our kind so that we capture further up in the application (eg UI layer). With the use of lambdas this is straightforward and clean to try/catch method calls to the service client.</li>
<li><strong>logging strategy particularly for debugging</strong>: you are going to need to debug payloads at some stage. Personally, I hate stepping through and that doesn&#8217;t help outside of development environments. So, a good set of logging is needed to. I&#8217;m still surprised how often code doesn&#8217;t have this.</li>
</ul>



<h2>Test automation pyramid</h2>

<p>Now that we know what code we need to write, what types of tests are we likely to need? If you are unfamiliar with the test automation pyramid or my specific usage see <a href="http://blog.goneopen.com/2010/08/test-automation-pyramid-review/">test automation pyramid review</a> for more details.</p>

<h3>System Tests</h3>


<ul>
<li>combine methods for workflow</li>
<li>timing acceptance tests</li>
</ul>



<h3>Integration Tests</h3>


<ul>
<li>different scenarios on each method</li>
<li>exception handling (eg bad credentials)</li>
</ul>



<h3>Unit Tests</h3>


<ul>
<li>Each method with mock (also see <a href="http://kashfarooq.wordpress.com/2008/11/29/mocking-wcf-services-with-rhinomocks/">mocking webservices</a>)</li>
<li>exception handling on each method</li>
<li>mapper tests</li>
</ul>



<h2>More classes!</h2>

<p>Without going into implementation details, all of this means that there is a boiler plate of likely classes. Here&#8217;s what I might expect to see in one of my solutions. A note on conventions: a slash &#8216;/&#8217; denotes folder rather than file; &lt;Service&gt;\&lt;Model&gt;\&lt;EachMethod&gt; is specific to your project and indicates that there is likely to be one or more of that type; names with a <code>.xml</code> are xml and all others if not folders are <code>.cs</code> files.</p>



<pre>
  Core/
    ServiceReference/
      I&lt;Service&gt;Client
      &lt;Service&gt;Exception
    Domain/
      &lt;Model&gt;
      ServiceReference/
        Credential&lt;Model&gt;
  
  Infrastructure/
    Service References/                  &lt;-- auto generated from Visual Studio ServiceModel
    Web Reference/                       &lt;-- auto generated from Visual Studio WSE3
    ServiceReference/
      &lt;Service&gt;Client
      Mapper/
        &lt;Model&gt;Mapper
  
  Tests.System/
    Acceptance/
      ServiceReference/
        &lt;Service&gt;/
          WorkflowTest
          TimingTest
    Manual/
      ServiceReference/
         &lt;Service&gt;-soap-ui.xml
  
  Tests.Integration/
    ServiceReference/
      &lt;Service&gt;/
        &lt;Method&gt;Test
  
  Tests.Unit/
    ServiceReference/
      &lt;Service&gt;/
        ConstructorTests
        &lt;Method&gt;Test
        ExceptionsTest
        Mappers/
          &lt;Model&gt;Test
        Security/
          CredentialTest                  &lt;-- needed if header credential
    Fixtures/
      ServiceReference/
        &lt;Service&gt;/
          Mock/Fake&lt;Service&gt;Client        
          Credentials.xml
          Request.xml                     &lt;-- needed if WSE3
          Response.xml                    &lt;-- needed if WSE3
      Domain/
        &lt;Model&gt;ObjectMother
        ServiceReference/
          Credential&lt;Model&gt;ObjectMother   &lt;-- needed if header credential
</pre>

<p>  </p>

<h2>That&#8217;s a whole lot more code!</h2>

<p>Yup, it is. But each concern and test is now separated out and you can work through them independently and systematically. Here&#8217;s my point, you can deal with these issues now and have a good test bed so that when changes come through you have change tolerant code and know you&#8217;ve been as thorough as you can be with what you presently know. Or, you can deal with it later at integration time when you can ill afford to be the bottle neck in the high visible part of the process.</p>

<h3>Potential coding order</h3>

<p>Now, that we might have a boilerplate of options, I tend to want to suggest an order. With the test automation pyramid, I suggest to design as a sketch and domain model/services first. Then system test stub writing, then come back through unit and integration tests before completing\implementing the system test stubs. Here&#8217;s my rough ordered list:</p>


<ol>
<li>have a data mapping document &#8211; Excel, Word or some form table is excellent often provided by BAs &#8211; you still have to have some analysis of differences between your domain and their&#8217;s</li>
<li>generate your <code>Service Reference</code> or <code>Web Reference</code> client proxy code &#8211; I want to see what the models and endpoints &#8211; I may play with them via soapUI &#8211; but usually leave that for later if at all needed</li>
<li>write my system acceptance tests stubs &#8211; here I need to understand how these services fit into the application and what the end workflow is going to be. For example, I might write these as user story given/when/then scenarios. I do not try and get these implement other than compiling because I will come back to them at the end. I just need a touch point of the big picture.</li>
<li>start writing unit tests for my Service Client &#8211; effectively, I am doing test-first creation of my I&lt;Service&gt;Client making sure that I can use each method with an injected Mock/Fake&lt;Service&gt;Client. </li>
<li>unit test out my mappers &#8211; by now, I will be thinking about the request/response cycle and will need to creating ObjectMothers to be translated into the service reference domain model to be posted. I might be working in the other direction too &#8211; which is usually a straightforward mapping but gets clearer once you start integration tests.</li>
<li>integration test on each method &#8211; once I have a good set of mappers, I&#8217;ll often head out to the integration point and check out how broken my assumptions about the data mapping are. Usually, as assumptions break down I head back into the unit test to improve the mappers so that the integration tests work &#8211; this is where the most work occurs!</li>
<li>at this point, I now need good <span class="caps">DEBUG </span>logging and I&#8217;ll just ensure that I am not using the step-through debugger but rather good log files at <span class="caps">DEBUG </span>level.</li>
<li>write system timing tests because sometimes there is an issue that the customer needs to be aware of</li>
<li>system tests that can be implemented for the unit/integration tests for the method implements thus far</li>
<li>add exception handling unit tests and code</li>
<li>add credential headers (if needed)</li>
<li>back to system tests and finish off and implement the original user stories</li>
<li>finally, sometimes, we need to create a set of record-and-replay tests for other people testing. SoapUI is good for this and we can easily save them in source for later use. </li>
</ol>



<h3>Some problems</h3>

<p>Apart from having presented any specific code, here are some problems I see:</p>


<ul>
<li><strong>duplication</strong>: your I&lt;Service&gt;Client and the proxy generated once is probably very similar with the difference it that your one returns your domain model objects. I can&#8217;t see how to get around this given your I&lt;Service&gt;Client is an anti-corruption class.</li>
<li><strong>namespacing/folders</strong>: I have suggested <code>ServiceReference/&lt;Service&gt;/</code> as folder structure. This is a multi-service structure so you could ditch the &lt;Service&gt; folder if you only had one. </li>
<li><strong>Fixtures.ServiceReference.&lt;Service&gt;.Mock/Fake&lt;Service&gt;Client</strong>: this implementation is up to you. If you are using ServiceModel then you have an interface to implement against. If you are using <span class="caps">WSE3 </span>you don&#8217;t have an interface &#8211; try extending through @partial@s or wrapping with another class.</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/test-automation-pyramid-and-webservices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Automation Pyramid &#8211; review</title>
		<link>http://blog.goneopen.com/2010/08/test-automation-pyramid-review/</link>
		<comments>http://blog.goneopen.com/2010/08/test-automation-pyramid-review/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 19:11:45 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[test automation pyramid]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/test-automation-pyramid-review/</guid>
		<description><![CDATA[Test Automation Pyramid This review has turned out to be a little longer than I expected. I have been using my own layering of the test automation pyramid and the goal was to come back and check it against the current models. I think that my usage is still appropriate but because it is quite [...]]]></description>
			<content:encoded><![CDATA[<h1>Test Automation Pyramid</h1>

<p>This review has turned out to be a little longer than I expected. I have been using my own layering of the test automation pyramid and the goal was to come back and check it against the current models. I think that my usage is still appropriate but because it is quite specific it wouldn&#8217;t work for all teams. So I might pick and choose between the others when needed. If you write line of business web applications which tend to have integration aspects then I think this might be useful. The key difference from the other models is my middle layer in the pyramid is perhaps a little more specific as I try and recapture the idea of integration tests within the context of xUnit tests. Read on if you are interested &#8211; there are some bullet points at the end if you are familiar with the different models. Just a disclaimer that reference point is .Net libraries and line-of-business web applications because of my work life at the moment. I suggesting something slightly different than say <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2010/08/24/an-effective-testing-strategy.aspx">this approach</a></p>

<h1>A little history</h1>

<p>The test automation pyramid has been credited to Mike Cohn of <a href="http://blog.mountaingoatsoftware.com">Mountain Goat Software</a>. It is a rubric concerning three layers that is foremostly concerned with how we think about going about testing &#8211; what types of tests we run and how many of each. While various authors, have modified the labels, it has changed very little and I suspect that is because its simplicity captures people&#8217;s imagination. In many ways, it makes a elementary point: automating your manual testing approach is not good enough particularly if that testing was primarily through the <span class="caps">GUI.</span> Mike explains that this was the starting point for the pyramid, he  <a href="http://blog.mountaingoatsoftware.com/the-forgotten-layer-of-the-test-automation-pyramid/comment-page-1#comment-66484">says</a>, </p>

<blockquote><p>The first time I drew it was for a team I wanted to educate about UI testing. They were trying to do all testing through the UI and I wanted to show them how they could avoid that. Perhaps since that was my first use it, that&#8217;s the use I&#8217;ve stuck with most commonly.</p></blockquote>

<p>Instead, change the nature of the tests &#8211; there is a lot of common sense to this. I&#8217;ll take for instance a current web application I am working on. I have a test team that spend a lot of time testing the application through the browser <span class="caps">UI.</span> It is a complex insurance application that connects to the company&#8217;s main system. Testers are constantly looking at policies and risks and checking data and calculations. In using the <span class="caps">UI, </span>however, they have tacit knowledge of what they are looking at and why &#8211; they will have knowledge about the policy from the original system and the external calculation engine. It is this tacit knowledge and the knowledge about the context &#8211; in this case, a specific record (policy) that meets a criteria &#8211; that is difficult to automate in its raw form. Yet, each time that do a manual test in this way the company immediately looses its investment in this knowledge but allowing it to be in the head of only one person. Automating this knowledge is difficult however. All this knowledge is wrapped into specific examples found manually. The problem when you automate this knowledge is that it is example-first testing and when you are testing against data like this today&#8217;s passing test may fail tomorrow. Or even worse the test may fail the day after when you can&#8217;t remember a lot about the example! Therefore, the test automation pyramid is mechanism to get away from a reliance on brittle end-to-end testing and the desire to simply automate your manual testing. It moves towards layering your testing &#8211; making multiple types of tests, maintaining boundaries, testing relationships across those boundaries and being attentive to the data which flows.  </p>

<p>Here&#8217;s the three main test automation pyramids out there in the wild. Take a look at these and then I will compare them below in a table and put them alongside my nomenclature.</p>

<h2>Cohn</h2>

<p><img src="../../../wp-content/uploads/2010/08/cohn-test-automation-pyramid.png" alt="Cohn" /></p>

<h2>Mezaros</h2>

<p><img src="../../../wp-content/uploads/2010/08/mezaros-test-automation-pyramid.png" alt="Mezaros" /></p>

<h2>Crispin</h2>

<p><img src="../../../wp-content/uploads/2010/08/crispin-test-automation-pyramid.png" alt="Crispin" /></p>


<h1>Test Automation Pyramid: a comparison</h1>



<pre>
	
   Cohn       Mezaros        Crispin             Suggested
   
                            (exploratory)      (exploratory)
     UI**      System          GUI               System
   Service    Component    Acceptance (api)    Integration
    Unit        Unit        Unit/Component         Unit  

</pre>




<p> ** in a recent <a href="http://blog.mountaingoatsoftware.com/the-forgotten-layer-of-the-test-automation-pyramid">blog post and subsequent comments</a> Mike agrees with others that the UI layer may be better called the &#8220;End-to-End&#8221; tests. Mike points out that when he started teaching this 6-7 years ago the term UI was the best way to explain to people the problem. And that problem being that automating manual tests meaning automating <span class="caps">GUI </span>tests and that the result is (see <a href="http://www.agilejournal.com/articles/columns/column-articles/2717-continuous-testing-building-quality-into-your-projects">Continuous Testing: Building Quality into Your Projects</a>): </p>

<blockquote><p><strong>Brittle</strong>. A small change in the user interface can break many tests. When this is repeated many times over the course of a project, teams simply give up and stop correcting tests every time the user interface changes.<br />
<strong>Expensive to write</strong>. A quick capture-and-playback approach to recording user interface tests can work, but tests recorded this way are usually the most brittle. Writing a good user interface test that will remain useful and valid takes time.<br />
<strong>Time consuming</strong>. Tests run through the user interface often take a long time to run. I&#8217;ve seen numerous teams with impressive suites of automated user interface tests that take so long to run they cannot be run every night, much less multiple times per day.</p></blockquote>

<h2>The pyramid gets it shape because:</h2>


<ul>
<li>Large numbers of very small unit tests &#8211; set a foundation on simple tests</li>
<li>Smaller number of functional tests for major components </li>
<li>Even fewer tests for the entire application &amp; workflow</li>
</ul>



<p>With a cloud above because:</p>


<ul>
<li>there are always some tests that need not or should not be automated</li>
<li>you could just say that system testing requires manual and automated testing</li>
</ul>



<p>General rules:</p>


<ul>
<li>need multiple types of tests</li>
<li>tests should be complimentary</li>
<li>while there looks like overlap, different layers test at a different abstraction</li>
<li>it is harder to introduce a layered strategy</li>
</ul>



<p>So, as Mezaros points out, multiple types of tests aware of boundaries are important:</p>

<p><img src="../../../wp-content/uploads/2010/08/mezaros-mutliple-tests.png" alt="Mezaros - Why We Need Multiple Kinds of Tests" /></p>

<h2>Compare and Contrast</h2>

<p>Nobody disagrees that the foundation are unit tests. Unit tests tell us exactly which class/method is broken. xUnit testing is dominant here as an approach and this is a well documented approach regardless of classical <span class="caps">TDD, </span>mocking <span class="caps">TDD </span>or fluent-language style <span class="caps">BDD </span>(eg should syntax helpers, or given/when/then or given/it/should). Regardless of the specifics, each test tests one thing, is written by the developer, is likely to have a low or no setup/teardown overhead, should run and fail fast and is the closest and most fine grained view of the code under test.</p>

<p>There are some slight differences that may be more than nomenclature. Crispin includes component testing in the base layer whereas Mezaros puts it as the next layer (which he defines the next layer as functional tests of major components). I&#8217;m not that sure that in practice they would look different. I suspect Crispin&#8217;s component testing would require mocking strategies to inject dependencies and isolate boundaries. Therefore, the unit/component of Crispin suggests to me that the unit test can be on something larger than a &#8220;unit&#8221; as long as it still meets the boundary condition of being isolated. One question I would have here for Crispin is in the unit tests would you include for instance tests with a database connection? Does this count as a component or an api? </p>

<p>The second layer starts to see some nuances but tends toward telling us which components are at fault. These are tested by explicitly targeting the programatic boundaries of components. Cohn called his services while Crispin, <span class="caps">API.</span> Combine that with Mezaros&#8217; component and all are suggesting that there is size of form within the system &#8211; a component, a service &#8211; is bigger than the unit but smaller than the entire system. For Mezaros, component tests would also test complex business logic directly. For Cohn, the service layer is a the api (or logical layer) in between the user interface and very detailed code. He <a href="http://blog.mountaingoatsoftware.com/the-forgotten-layer-of-the-test-automation-pyramid">says</a>, &#8220;service-level testing is about testing the services of an application separately from its user interface. So instead of running a dozen or so multiplication test cases through the calculator&#8217;s user interface, we instead perform those tests at the service level&#8221;. So what I think we see in the second layer is expedient testing in comparison to the <span class="caps">UI.</span> Although what I find hard to see is whether or not this level expects dependencies must be running within an environment. For example, Mezaros and Crispin both suggest that we might be running <span class="caps">FIT </span>which often require a working environment in place (because of the way they are written). In practice, I find this a source of confusion that is worth considering. (This is what I return to in a clarification of integration testing.)</p>

<p>On to the top layer. This has the least amount of tests and works across the entire application and focuses often on workflow. Cohn and Crispin focus on the UI to try and keep people about keeping these tests small. Mezaros makes a more interesting move to subsume that UI testing into system testing. Inside system tests he also uses acceptance testing (eg <span class="caps">FIT</span>) and manual tests. Crispin also account for manual testing in the cloud above the pyramid. Either way manual testing is still an important part of a test automation strategy. For example the use of record-and-replay tools, such as, selenium or <span class="caps">WATIR</span>/N have made browser-based testing UI testing easier. You can use these tools to help script browser testing and then you have the choice whether to automate or not. However, UI testing still suffers from entropy and hence is the hardest to maintain over time &#8211; particularly if they are dependent data. </p>

<p>Here are some of the issues I find coming up out of these models. </p>


<ul>
<li>the test automation pyramid requires a known solution architecture with good boundary definition that many teams haven&#8217;t made explicit (particularly through sketching/diagrams)</li>
<li>existing notions of the &#8220;unit&#8221; test are not as subtle as an &#8220;xUnit&#8221; unit test</li>
<li>people are too willing to accept that some boundaries aren&#8217;t stub-able &#8211; often pushing unit tests into the service/acceptance layer</li>
<li>developers are all too willing to see (system) <span class="caps">FIT </span>tests as the testers (someone else&#8217;s) responsibility</li>
<li>it is very hard to get story-test driven development going and the expense of <span class="caps">FIT </span>quickly outweighs benefits</li>
<li>we can use xUnit type tests for system layer tests (eg xUnit-based StoryQ or Cucumber)</li>
<li>you can combine different test runners for the different layers (eg xUnit, Fitnesse and Selenium and getting a good report)</li>
<li>developers new to <span class="caps">TDD </span>and unit testing tend to use test-last strategies that are of the style best suited for system layer tests &#8211; and get confused why they see little benefit</li>
</ul>



<h1>Modified definition of the layers</h1>

<p>Having worked with these models, I want to propose a slight variation.</p>


<ul>
<li><strong>Unit</strong> &#8211; a test that has no dependencies</li>
<li><strong>Integration</strong> &#8211; a test that has only one dependency and tests one interaction</li>
<li><strong>System</strong> &#8211; a test that has one-or-more dependencies and many interactions</li>
<li><strong>Exploratory</strong> &#8211; test that is not part of the regression suite, nor should have traceability requirements</li>
</ul>



<h2>Unit tests</h2>

<p>There should be little disagreement about what good xUnit tests: it is well documented although rarely practised in line-of-business applications. As <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=126923">Michael Feathers says</a>, </p>

<blockquote><p>A test is not a unit test if:<br />
  * it talks to the database<br />
  * it communicates across the network<br />
  * it touches the file system<br />
  * it can&#8217;t run at the same time as any of your other unit tests<br />
  * you have to do special things to your environment (such as editing config files) to run it<br />
Tests that do these things aren&#8217;t bad. Often they are worth writing, and they can be written in a unit test harness. However, it is important to keep them separate from true unit tests so that we can run the unit tests quickly whenever we make changes.</p></blockquote>

<p>Yet often unit tests are difficult because it works against the grain of the application framework. I have documented my approach elsewhere for an <span class="caps">MVC </span>application that I not only unit test the usual suspects of <a href="http://blog.goneopen.com/2008/11/fakes-arent-object-mothers-or-test-builders/">domain models</a>, services and various helpers such as <a href="http://blog.goneopen.com/2010/03/fluent-configurator-thoughts-on-getting-a-design/">configurators</a> or data mappers but also my touch points with the framework such as routes, controllers, action redirects (see <a href="http://mvccontrib.codeplex.com">MvcContrib</a> which I contributed to with the help of a colleague). I would expect unit test of this kind to be test-first because it about design with a touch of verification. If you can&#8217;t test-first this type of code base it might be worthwhile spending a little understanding what part of the system you are unable understand (sorry mock out!). Interestingly, I have found that I can test-first <span class="caps">BDD</span>-style parts of my <span class="caps">GUI </span>when in the browser and using jQuery and JsSpec (or QUnit) (<a href="http://github.com/toddb/jquery.storyq">here&#8217;s an example</a>) &#8211;  you have to treat javascript as first-class citizen at this point so here&#8217;s a helper for <a href="http://github.com/toddb/jQuery-Plugin-Generator">generating the scaffolding for the jquery plugin</a>.</p>

<p>So I have a check list unit tests I expect to find in a line-of-business unit test project:</p>


<ul>
<li>model validations</li>
<li>repository validation checking</li>
<li>routes</li>
<li>action redirects</li>
<li>mappers</li>
<li>any helpers</li>
<li>services (in the <span class="caps">DDD </span>sense)</li>
<li>service references (web services for non-Visual Studio people)</li>
<li>jquery</li>
</ul>




<h2>Integration tests</h2>

<p>Integration tests may have a bad name if you agree with <a href="http://www.infoq.com/presentations/integration-tests-scam">JB Rainsberger that integration tests are a scam</a> because you would see integration tests as exhaustive testing. I agree with him on that count so I have attempted to reclaim integration testing and use the term quite specifically in the test automation pyramid. I use it to mean to test only <strong>one dependency and one interaction at a time</strong>. For example, I find this approach helpful with testing repositories (in the <span class="caps">DDD </span>sense). I do integration test repositories because I am interested in my ability to manage an object lifecycle through the database as the integration point. I therefore need tests that prove <span class="caps">CRUD</span>-type functions through an identity &#8211; Eric Evans (DDD, p.123) has a diagram of an object&#8217;s lifecycle that is very useful to show the links between an object lifecycle and the repository. </p>

<p><img src="../../../wp-content/uploads/2010/08/evans-life-cyle-domain-object.jpg" alt="Title" /></p>

<p>Using this diagram, we are interested in the identity upon saving, retrieval, archiving and deletion because these touch the database. For integration tests, we are likely to less interested in creation and updates because they wouldn&#8217;t tend to need the dependency of the database. These then should be pushed down to the unit tests &#8211; such as validation checking on update. </p>

<p>On the web services front, I am surprised how often I don&#8217;t have integration tests for them because the main job of my code is (a) test mappings between the web service object model and my domain model which is a unit concern or (b) the web services use of data which I would tend to make a system concern. </p>

<p>My checklist in the integration tests is somewhat less than unit tests:</p>


<ul>
<li>repositories</li>
<li>service references (very lightly done here just trying to think about how identity is managed)</li>
<li>document creation (eg <span class="caps">PDF</span>)</li>
<li>emails</li>
</ul>



<h2>System tests</h2>

<p>System testing is the end-to-end tests and it covers any number of dependencies to satisfy the test across scenarios. We then are often asking various questions in the system testing, is it still working (smoke)? do we have problems when we combine things and they interact (acceptance)? I might even have a set of tests are scripts for manual tests.</p>

<p>I find <strong>smoke tests</strong> invaluable. To keep them cost effective, I also keep them slim and often throw some away once I have found that the system has stabilised and the cost of maintaining is greater than the benefit. Because I tend to write web applications my smoke tests are through the UI and I use record-and-replay tools such as selenium. My goal with these tests is to target parts of the application that are known to be problematic so that I get as earlier a warning as possible. These types of system tests must be run often &#8211; and often here means starting in the development environment and then moving through the build and test environments. But running in all these environment comes with a significant cost as each tends to need its own configuration of tools. Let me explain because the options all start getting complicated but may serve as a lesson for tool choice. In one project, we used selenium. So we using selenium <span class="caps">IDE </span>in Firefox for record and replay. Developers use this for their development/testing (and devs have visibility of these tests in the smoke test folder). These same scripts were deployed through onto the website so that testing in testing environments could be done through the browser (uses selenium core and located in the web\tests folder &#8211; same tests but available for different runners). On the build server, the tests through seleniumHQ (because we ran Hudson build server) &#8211; although in earlier phases we had actually used selenium-RC with NUnit but I found that in practice hard to maintain [and we could have used Fitnesse alternatively and selenese!]. As an aside, we found that we also used the smoke tests as our demo back to client so we had them deploy on the test web server so that run through the browser (using the selenium core).  To avoid maintenance costs, the trick was to write them specific enough to test something real and general enough not to break over time. Or if they <em>do</em> break it doesn&#8217;t take too long to diagnose and remedy. As an aside, selenium tests when broken into smaller units use a lot of block-copy inheritance (ie copy and paste). I have found that this is just fine as long as you use find-and-replace strategies for updating data. For example, we returned to this set of tests two years later and they broke because of date specific data that had expired. After 5 minutes I had worked out that the tests with a find-and-replace for a date would fix the problem. I was surprised to tell the truth!</p>

<p>Then there are the <strong>acceptance tests</strong>. These are the hardest to sustain. I see them as having two main functions: they have a validation function because they link customer abstractions of workflow with code (validation). The other is that they ensure good design of the code base. A couple of widely used approaches to acceptance type tests are <span class="caps">FIT</span>/Fitnesse/Slim/FitLibraryWeb (or StoryTeller) and <span class="caps">BDD</span>-style user stories (eg StoryQ, Cucumber). Common to both is to create an additional layer of abstraction for the customer view of the system and another layer than wires this up to the system under test. Both are well documented on the web and in books so I won&#8217;t go labour the details here (just a wee note that I you can see a .net bias simply because of my work environment rather than personal preference). I wrote about acceptance tests and the need for a fluent inteface level in a <a href="../../2010/03/test-automation-pyramid-asp-net-mvc/">earlier entry</a>:</p>

<blockquote><p>I find that to run maintainable acceptance tests you need to create yet another abstraction. Rarely can you just hook up the <span class="caps">SUT </span>api and it works. You need setup/teardown data and various helper methods. To do this, I explicitly create &#8220;profiles&#8221; in code for the setup of  data and exercising of the system. For example, when I wrote a Banner delivery tool for a client (think OpenX or GoogleAds) I needed to create a &#8220;Configurator&#8221; and an &#8220;Actionator&#8221; profile. The Configurator was able to create a number banner ads into the system (eg html banner on this site, a text banner on that site) and the Actionator then invoked 10,000 users on this page on that site. In both cases, I wrote C# code to do the job (think an internal <span class="caps">DSL </span>as a fluent interface) rather than say in fitnesse.</p></blockquote>

<p>I have written a series of blogs on <a href="http://blog.goneopen.com/2009/06/dsl-part-i-writing-a-fluent-interface-for-configuration-in-c/">building configurators through fluent interfaces  here</a>.</p>

<p>System tests may or may not have control over setup and teardown. If you do, all the better. If you don&#8217;t you&#8217;ll have to work a lot harder in the setup phase. I am currently working on a project which a system test works across three systems. The first is the main (legacy &#8211; no tests) system, the second a synching/transforming system and the third which is the target system. (Interestingly, the third only exists because no one will tackle extending the first and the second only because the third needs data from the first &#8211; it&#8217;s not that simple but you get the gist.) The system tests in this case become one less of testing that the code is correct. Rather it is more one of does the code interact with the data from the first system in ways that we would expect/accept? As a friend pointed out this becomes an issue akin to process control. Because we can&#8217;t setup data in the xUnit fashion, we need to query the first system directly and cross reference against third system. In practice, the acceptance test helps us refine our understanding of the data coming across &#8211; we find the implicit business rules and in fact data inconsistencies, or straight out errors.</p>

<p>Finally <strong>manual tests</strong>. When using Selenium my smoke tests are my manual tests. But in the case of web services or content gateways, there are times that I want to just be able to make one-off (but repeatable) tests that require tweaking each time. I may then be using these to inspect results too. These make little sense to invest in automation but they do make sense to have checked into source leaving it there for future reference. Some SoapUI tests would fit this category.</p>

<p>A final point I want to make about the nature of system tests. They are both written first and last. Like story-test driven development, I want acceptance (story tests) tests written into the code base to begin with and then set to pending (rather than failing). I then want them to be hooked up to the code as the final phase and set to passing (eg Fitnesse fixtures). By doing them last, we already have our unit and integration tests in place. In all likelihood by the time we get to the acceptance tests we are now dealing with issues of design validation in two senses. One, that we don&#8217;t understand the essential complexity of the problem space &#8211; there are things in there that we didn&#8217;t understand or know about that are now coming into light and this suggests that we will be rewriting parts of the code. Two, that the design of code isn&#8217;t quite as <span class="caps">SOLID </span>as we thought. For example, I was just working on an acceptance test where I had do a search for some data &#8211; the search mechanism I found had constraints living the <span class="caps">SQL </span>code that I couldn&#8217;t pass in and I had to have other data in the database. </p>

<p>For me, tests are the ability for us as coders to have conversations with our code. By the time we have had the three conversations of unit, integration and acceptance, I find that three is generally enough to have a sense that our design is good enough. The acceptance is important because helps good layering and enforce that crucial logic doesn&#8217;t live in the UI layer but rather down in the application layer (in the <span class="caps">DDD </span>sense). The acceptance tests, like the UI layer, are both clients of the application layer. I often find that the interface created in the application layer not surprisingly services the UI layer that will require refactoring for a second client. Very rarely is this unhelpful and often it finds that next depth of bugs.</p>

<p>My system tests checklist:</p>


<ul>
<li>acceptance</li>
<li>smoke</li>
<li>manual</li>
</ul>



<h2>Exploratory</h2>

<p>The top level system and exploratory testing is all about putting it together so that people across different roles can play with the application and use complex heuristics to check its coding. But I don&#8217;t think the top level is really about the user interface <em>per se</em>. It only looks that way because the <span class="caps">GUI </span>is most generalised abstraction that we believe that customers and testers believe that they understand the workings of the software. Working software and the <span class="caps">GUI </span>should not be conflated.  Complexity at the top-most level is that of many dependencies interacting with each other &#8211; context is everything. Complexity here is not linear. We need automated system testing to follow critical paths that create combinations or interactions that we can prove do not have negative side effects. We also need exploratory testing which is deep, calculative yet ad hoc that attempts to create negative side effects that we can then automate. Neither strategy aspires for illusive, exhaustive testing &#8211; as JB Rainsberger argues &#8211; which is the scam of integration testing. </p>

<h2>General ideas</h2>

<p>Under this layering, I find a (dotnet) solution structure of three projects (<code>.csproj</code>) is easier to maintain and importantly the separation helps with the build server. Unit tests are built easily, run in place and fail fast (seconds not minutes). The integration tests require more work because you need the scripting to migrate up the database and seed data. These obviously take longer. I find the length of these tests and their stability are a good health indicator. If they don&#8217;t exist or are mixed up with unit tests &#8211; I worry a lot. For example, I had a project that these were mixed up and the tests took 45 minutes to run so tests were rarely run as a whole (so I found out). As it turned out many of the tests were unstable. After splitting them, we got unit tests to under 30 seconds and then started the long process of reducing integration test time down which we got down to a couple of minutes on our development machines. Doing this required splitting out another group of tests that were mixed up into the integration tests. These were in fact system tests that tested the whole of the system &#8211; that is, there are workflow tests that require all of the system to be in place &#8211; databases, data, web services, etc. These are the hardest to setup and maintain in a build environment. So we tend to do the least possible. For example, we might have selenium tests to smoke test the application through the <span class="caps">GUI </span>but it is usually the happy path as fast as possible that exercises that all are ducks are lined up. </p>

<h2>Still some problems</h2>

<p>Calling the middle layer integration testing is still problematic and can cause confusion. I introduced integration because it is about the longer running tests which required the dependency of an integration point. When explaining to people, they quickly picked up on the idea. Of course, they also bring their own understanding of integration testing which is closer to the point  that Rainsberger is making. </p>

<h2>Some general points</h2>


<ul>
<li>a unit test should be test first</li>
<li>an integration test with a database tests is usually the test of the repository to manage identity through the lifecycle of a domain object</li>
<li>a system test must cleanly deal with duplication (use other libraries)</li>
<li>a system test assertion is likely to be test-last</li>
<li>unit, integration and system tests should each have their own project</li>
<li>test project referencing should cascade down from system to integration through to the standalone unit</li>
<li>the number and complexity of tests across the projects should reflect the shape of the pyramid</li>
<li>the complexity of the test should be inversely proportional to the shape of the pyramid</li>
<li>unit and integration test object mothers are subtly different because of identity</li>
<li>a system test is best for testing legacy data because it requires all components in place</li>
<li>some classes/concerns might have tests split across test projects, e a repository class should have both unit and integration tests</li>
<li>framework wiring code should be pushed down to unit tests, such as, in mvc routes, actions and redirects, </li>
<li><span class="caps">GUI </span>can sometime be unit tested, eg jQuery makes unit testing of browser widgets realistic</li>
<li>success of pyramid is an increase in exploratory testing (not an increase in manual regressions)</li>
<li>the development team skill level and commitment is the greatest barrier closely followed by continuous integration</li>
</ul>



<h2>Some smells</h2>


<ul>
<li>time taken to run tests is not inversely proportional to the shape of the pyramid</li>
<li>folder structure in the unit tests that in no way represents the layering of the application</li>
<li>only one test project in a solution</li>
<li>acceptance tests written without an abstraction layer/library</li>
</ul>



<h2>References</h2>


<ol>
<li><a href="http://blog.mountaingoatsoftware.com/the-forgotten-layer-of-the-test-automation-pyramid">The Forgotten Layer of the Test Automation Pyramid</a></li>
<li><a href="http://xunitpatterns.com/~gerard/agile2008-Concept2BacklogTutorial-AP2.pdf">From backlog to concept</a></li>
<li><a href="http://lisacrispin.com/downloads/AgileTestingOverview.pdf">Agile testing overview</a></li>
<li><a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2010/08/24/an-effective-testing-strategy.aspx">Standard implementation of test automation pyramid</a></li>
</ol>

]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/test-automation-pyramid-review/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>architects-and-agile</title>
		<link>http://blog.goneopen.com/2010/08/architects-and-agile/</link>
		<comments>http://blog.goneopen.com/2010/08/architects-and-agile/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:44:48 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/architects-and-agile/</guid>
		<description><![CDATA[This was just a nice little presentation from infoq on agilists and architects that I made some notes on. Architects: Enterprise, Data, Technical, Integration Architects: usually disconnected from the application (cf application architect) &#8211; shared across business unit or development stream &#8211; against reckless proliferation of tools &#8211; often charged with stability How does self-empowered [...]]]></description>
			<content:encoded><![CDATA[<p>This was just a nice little presentation from <a href="http://www.infoq.com/presentations/agilists-and-architects">infoq on agilists and architects</a> that I made some notes on.</p>

<p>Architects:</p>

<p>Enterprise, Data, Technical, Integration Architects: usually disconnected from the application (cf application architect)<br />
 &#8211; shared across business unit or development stream<br />
 &#8211; against reckless proliferation of tools<br />
 &#8211; often charged with stability</p>

<p>How does self-empowered teams work with enterprise standards and reviews? </p>

<p>Even good people have been messed up by bad ideas. What is in agile for architects?<br />
 &#8211; transparency and visibility into progress<br />
 &#8211; up to date specification of functionality (through tests and also self checking)<br />
 &#8211; results in adaptable code (reuse/harvest after the fact rather than planned)</p>

<p>How to make it work? <br />
 &#8211; Architects as customers<br />
 &#8211; Architects as team members &#8230; means they are customers and techies</p>

<p>Architects are centrally to understanding how all the business holds together and can help with technical debt</p>

<p>Making estimates based on clean code and that on legacy code</p>]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/architects-and-agile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>a-quick-note-on-brooks</title>
		<link>http://blog.goneopen.com/2010/08/a-quick-note-on-brooks/</link>
		<comments>http://blog.goneopen.com/2010/08/a-quick-note-on-brooks/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:41:35 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/a-quick-note-on-brooks/</guid>
		<description><![CDATA[Accidental and essential complexity in software Brooks said that he believed the hard part of building software to be the specification, design and testing of the conceptual construct of software, not the labour of representing it, and testing the fidelity of that representation. This is not surprising that in the shift from writing software to [...]]]></description>
			<content:encoded><![CDATA[<h1>Accidental and essential complexity in software</h1>

<p>Brooks said that he believed the hard part of building software to be the specification, design and testing of the conceptual construct of software, not the labour of representing it, and testing the fidelity of that representation.</p>

<p>This is not surprising that in the shift from writing software to building software that we have separated out design from building, building from testing and testing from design. This process we would call waterfall and often we see people having a single-pass version in their mind&#8217;s eye.</p>

<p>Iterative and incremental is a shift from building software to growing software. That is, first make the system run and that add to it bit by bit while always keeping it a working system. Brooks points out that he finds that teams can grow much more complex entities in four months than they can build.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/a-quick-note-on-brooks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>gerald-mezaros-concept-to-backlog</title>
		<link>http://blog.goneopen.com/2010/08/gerald-mezaros-concept-to-backlog/</link>
		<comments>http://blog.goneopen.com/2010/08/gerald-mezaros-concept-to-backlog/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:38:51 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/gerald-mezaros-concept-to-backlog/</guid>
		<description><![CDATA[Notes from Gerald Mezaros on Concept to Backlog I was just re-reading Gerald Mezaros of the xunittestpatterns from his pdf of from concept to backlog and also having a look at his presntation on infoq. I was using him to think through an approach with a client. These are my notes from a while back. [...]]]></description>
			<content:encoded><![CDATA[<h1>Notes from Gerald Mezaros on Concept to Backlog</h1>

<p>I was just re-reading Gerald Mezaros of the <a href="http://xunittestpatterns.com">xunittestpatterns</a> from his <a href="http://www.infoq.com/presentations/From-Concept-to-Product-Backlog">pdf of from concept to backlog</a><br />
and also having a look at his presntation on <a href="http://www.infoq.com/presentations/From-Concept-to-Product-Backlog">infoq</a>.</p>

<p>I was using him to think through an approach with a client. These are my notes from a while back.</p>

<h1>The client</h1>

<p>The current situation is:</p>

<p> &#8211; that the product has gone to business case<br />
 &#8211; there are a list of major features and put into themes<br />
 &#8211; overall costing/effort estimates<br />
 &#8211; business staffing/engagement with vendors (skills list)<br />
 &#8211; end delivery date</p>

<p>We already have:<br />
 &#8211; existing product (architecture, infrastructure)<br />
 &#8211; set of tests/test strategy based on the test automation pyramid (fitnesse, selenium, nunit)</p>

<p>There is no:<br />
 &#8211; is there really a product design?<br />
 &#8211; release plan<br />
 &#8211; no user stories<br />
 &#8211; no story tests/acceptance criteria</p>

<p>Risks:<br />
 &#8211; is time going to be an issue with new features?<br />
 &#8211; will the existing architecture still hold?<br />
 &#8211; what the introduction of new platform (eg Sitecore)<br />
 &#8211; integration tests take 15 minutes to run (aka functional tests layer)</p>

<h1>Notes from the talk </h1>

<p><span class="caps">BDUF </span>vs <span class="caps">LRM </span>(last responsible moment)<br />
 &#8211; making better decision later</p>

<p>Product Envisioning<br />
Product Planning<br />
Product Execution</p>


<h2>Elevator Statement (Moore &#8211; Crossing the Chasm)</h2>

<p>For (target customers)<br />
who are dissatisfied (with current alternatives)<br />
our product is a (new product category)<br />
that provides (key problem-solving capabilities)<br />
unlike (the product alternativ)<br />
we have assembled (key &#8220;whole prodct&#8221; for features for our specific application)</p>

<p>Tensions:</p>

<p>- just in time analysis so that we don&#8217;t have inventory as waste</p>

<p>What have we done in our current project?</p>

<p>Main Features -<br />
Need:<br />
 &#8211; product design (eg screens, data models or messaging protocols &#8211; not software design) &#8211; barely sufficient to something the customer loves<br />
 &#8211; product behaviour (featurs and definition of scope)</p>

<p>We have:<br />
 &#8211; some high level architecture (dotnet, test strategy)<br />
 &#8211; do we need more of components?</p>

<p>What about a release plan?<br />
 &#8211; date &amp; features</p>

<p>Do we want use cases are deliverables of the project (yes &#8211; current implementation has)</p>

<p>Release Planning: (manage scope to fit budget)<br />
 &#8211; needing priorities around user stories (allow us some wiggle room)<br />
 &#8211; we have committed to the features, what about the stories? (that we don&#8217;t have)</p>]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/gerald-mezaros-concept-to-backlog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>subversion-conventions-notes</title>
		<link>http://blog.goneopen.com/2010/08/subversion-conventions-notes/</link>
		<comments>http://blog.goneopen.com/2010/08/subversion-conventions-notes/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:18:47 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/subversion-conventions-notes/</guid>
		<description><![CDATA[Moving to Subversion notes: I have included my copy of the pragmatic programmers (PP) Subversion book. Everything I would suggest is covered well enough in this book and I will refer to pages in this. I have also attached the free svn red book from oreilly. My assumption in these notes is that you haven&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<h1>Moving to Subversion notes:</h1>

<p>I have included my copy of the <a href="http://www.pragprog.com/press_releases/svn2">pragmatic programmers (PP) Subversion book</a>. Everything I would suggest is covered well enough in this book and I will refer to pages in this. I have also attached the free <a href="http://svnbook.red-bean.com/nightly/en/svn-book.pdf">svn red book from oreilly</a>. </p>

<p>My assumption in these notes is that you haven&#8217;t used <span class="caps">SVN </span>or are familiar with its strategies. In perforce, you have been using a mainline strategy (as documented in the wiki). Subversion does not use this strategy. You will need to get familiar with its approach. PP p54 says:</p>

<p>&#8220;Developers should use branches to separate the main <br />
line of development from code lines that have dif ferent <br />
life cycles, such as release branches and major code <br />
experiments. Tags are used to identify signi&iuml;&not;cant points <br />
in time, including releases and bug &iuml;&not;xes.&#8221;"</p>

<h1>Access to the repository:</h1>

<p>For read-only browsing access in a browser this will allow you to look at all the projects.</p>


<ul>
<li><code>https://domain/svn/</code></li>
</ul>



<p>For real work, checking out and committing with an <span class="caps">SVN </span>client:</p>


<ul>
<li><code>https://domain/svn/project/trunk</code></li>
</ul>



<h1><span class="caps">SVN</span> Clients:</h1>


<ul>
<li><strong>TortoiseSVN</strong> &#8211; <span class="caps">GUI </span>integration into explorer &#8211; http://tortoisesvn.net/downloads</li>
<li><strong>AnkhSVN</strong> &#8211; integration into Visual Studio &#8211; http://ankhsvn.open.collab.net/</li>
<li><strong>VisualSVN</strong> &#8211; integration into Visual Studio &#8211;  http://www.visualsvn.com/visualsvn/</li>
<li><strong><span class="caps">SVN </span>commandline</strong> &#8211; http://subversion.tigris.org/getting.html#windows</li>
</ul>



<p>Personally, I use tortoise and commandline and then also visual studio integration.</p>

<h1>Checking out:</h1>

<p>Everyone has their own naming conventions. Personally, when dealing with a trunk, I often check to a folder name with hyphen trunk in it. The name of the folder isn&#8217;t that important in the long run because it can be renamed.</p>



<pre>
 cd /path/to/src
 svn co https://domain/svn/project/trunk project-trunk
</pre>



<h1>Committing:</h1>

<p> <code>svn commit -m &quot;my check in&quot;</code>  (PP p.91)</p>

<p>But, note that you will have already need to have added a file. <span class="caps">GUI </span>client will help with this.</p>

<p>Adding might look like this in the command line: <code>svn add .</code>  (PP p.63)</p>

<h1>Organising the repository</h1>


<ol>
<li>There are also three folders for each project trunk, tags, branches (PP p.108)</li>
<li>We will <span class="caps">NOT </span>be running a multiple project repository because we will be using multiple repositories when needed (PP p.110)</li>
<li>Repositories can be linked via svn:externals when and if needed (PP p.135)</li>
</ol>



<h1>Using tags and branches</h1>

<p>This is all covered in Chapter 9 (PP p.111) including creating release branches, fixing bugs, etc.</p>

<h1>Naming conventions</h1>

<p>My suggestion is to use PP conventions (p. 114)</p>



<pre>
Thing to Name     Name Style            Examples 
Release branch    RB-rel                RB-1.0 
                                        RB-1.0.1a 
Releases          REL-rel               REL-1.0 
                                        REL-1.0.1a 
Bug fix branches  BUG-track             BUG-3035 
                                        BUG-10871 
Pre-bug fix       PRE-track             PRE-3035 
                                        PRE-10871 
Post-bug fix      POST-track            POST-3035 
                                        POST-10871 
Developer experiments TRY-initials-desc TRY-MGM-cache-pages 
                                        TRY-MR-neo-persistence
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/subversion-conventions-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perforcemigration-notes</title>
		<link>http://blog.goneopen.com/2010/08/perforcemigration-notes/</link>
		<comments>http://blog.goneopen.com/2010/08/perforcemigration-notes/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:08:39 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/perforcemigration-notes/</guid>
		<description><![CDATA[Instructions: http://www.perforce.com/perforce/doc.current/user/p4perlnotess.txt But, actually: % wget ftp://ftp.perforce.com/perforce/r09.1/bin.tools/p4perl.tgz (extract to /path/to/tmp/p4perl) extract to location /path/to/tmp/ Get: wget ftp://ftp.perforce.com/perforce/r09.1/bin.darwin80u/p4api.tgz (extract to /path/to/tmp/p4api) wget ftp://ftp.perforce.com/perforce/r09.1/bin.darwin80u/p4 extract to location /path/to/tmp/ p4 todd$ ls p4 p42svn.pl p4api p4api.tgz p4perl p4perl.tgz cd p4perl perl Makefile.PL &#8211;apidir ../p4api (from p4api.tgz) make make tests sudo make install Password: % perl -MP4 -e &#8220;print [...]]]></description>
			<content:encoded><![CDATA[<p>Instructions:<br />

http://www.perforce.com/perforce/doc.current/user/p4perlnotess.txt</p>

<p>But, actually:</p>

<p>% wget ftp://ftp.perforce.com/perforce/r09.1/bin.tools/p4perl.tgz (extract to /path/to/tmp/p4perl)</p>

<p>extract to location /path/to/tmp/</p>

<p>Get:</p>

<p><span>wget ftp://ftp.perforce.com/perforce/r09.1/bin.darwin80u/p4api.tgz  (extract to /path/to/tmp/p4api)<br /><br />
</span> wget ftp://ftp.perforce.com/perforce/r09.1/bin.darwin80u/p4</p>

<p>extract to location <br />
/path/to/tmp/</p>

<p>p4 todd$ ls<br />
p4		p42svn.pl	p4api		p4api.tgz	p4perl		p4perl.tgz</p>

<p><span>cd p4perl <br /><br />
</span> perl Makefile.PL &#8211;apidir ../p4api  (from p4api.tgz)<br />
<span>make<br /><br />
</span> make tests<br />
<span>sudo make install<br /><br />
</span> Password:</p>

<p>% perl -MP4 -e &#8220;print P4::Identify()&#8221; </p>

<p>Perforce &#8211; The Fast Software Configuration Management System.<br />
Copyright 1995-2009 Perforce Software.  All rights reserved.<br />
Rev. <span class="caps">P4PERL</span>/DARWIN9X86/2009.1.GA/205670 (2009.1 <span class="caps">API</span>) (2009/06/29).</p>

<p>Right now I am ready to do the migration: (I used version 91)</p>

<p>wget  http://p42svn.tigris.org/source/browse/*checkout*/p42svn/trunk/p42svn.pl?revision=91</p>

<p>% perl p42svn.pl usage</p>

<p>If you get errors then you have installation problems with perl and spent time sorting it out. (I had major problems that took me a couple of hours to sort out including updating, upgrading, installing, arrrggghhh)</p>

<p>perl p42svn.pl &#8211;user yours &#8211;password secret &#8211;port xx.xx.xx.xx:1666  &#8211;branch &#8220;//depot/project&#8221;=trunk &gt; svn.dump</p>

<p>Now, move that file to the windows box</p>

<p>Backon the windows box:</p>

<p>svnadmin create c:\Repositories\project<br />
svnadmin load c:\Repositories\project &lt; svn.dump</p>]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/perforcemigration-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jquery-bdd</title>
		<link>http://blog.goneopen.com/2010/08/jquery-bdd/</link>
		<comments>http://blog.goneopen.com/2010/08/jquery-bdd/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 02:06:04 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[test automation pyramid]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/08/jquery-bdd/</guid>
		<description><![CDATA[Notes from a jQuery session Structure of session: Jump into an example Build some new functionality Come back and see the major concepts Look at what is actually needed to treat javascript as a first-class citizen Different testing libraries Quick why a library in javascript? cross-browser abstraction (dynduo circa 1998 was still hard!) jQuery, MooTools, [...]]]></description>
			<content:encoded><![CDATA[<h1>Notes from a jQuery session</h1>

<h1>Structure of session:</h1>


<ul>
<li>Jump into an example</li>
<li>Build some new functionality</li>
<li>Come back and see the major concepts</li>
<li>Look at what is actually needed to treat javascript as a first-class citizen</li>
<li>Different testing libraries</li>
</ul>



<h1>Quick why a library in javascript?</h1>


<ul>
<li>cross-browser abstraction (dynduo circa 1998 was still hard!)</li>
<li>jQuery, MooTools, Extjs, Prototype, <span class="caps">GWT, YUI,</span> Dojo, &#8230;</li>
<li>I want to work with <span class="caps">DOM </span>with some UI abstractions &#8211; with a little general purpose</li>
<li>simple <span class="caps">HTML </span>traversing, event handling</li>
<li>also functional, inline style</li>
<li>I want plugin type architecture</li>
</ul>



<h1>Story plugin demo</h1>


<ul>
<li>Viewer of StoryQ results</li>
<li>StoryQ produces <span class="caps">XML, </span>this widget gives the <span class="caps">XML </span>a pretty viewer</li>
</ul>



<h2>A screenshot and demo</h2>


<ul>
<li><a href="http://github.com/toddb/jquery.storyq/raw/master/screenshot.png">jquery storyq plugin</a></li>
<li><a href="http://github.com/toddb/jquery.storyq">downloadable</a></li>
</ul>



<h2>What would your acceptance criteria be? What do you think some of the behaviours of this page are?</h2>

<p>Acceptance: </p>

<p>eg should display the <span class="caps">PROJECT </span>at the top with the number of tests</p>

<p>Behaviours:</p>

<p>think in terms of themes: data, display, events</p>

<h2>The tests &#8230; what does the application do?</h2>


<ul>
<li>run the tests and see the categories</li>
<li>data loading: xml</li>
<li>display: traversing xml and creating html</li>
<li>events: click handlers</li>
</ul>



<h1>Let&#8217;s build some new functionality!</h1>

<p>Goal: add &#8220;Expand All | Contract All | Toggle&#8221; functionality to the page</p>

<h2>Acceptance:</h2>


<ul>
<li>The user should be able to expand, collapse or toggle the tree</li>
</ul>



<h2>Specs</h2>

<p>Display:<br />
* should show &#8220;Expand All | Contract All | Toggle&#8221;<br />
Events:<br />
* should show all results when clicking expand all<br />
* should show only top class when clicked contract all<br />
* should toggle between all and one when clicking on toggle</p>

<h1>Coding: Add acceptance</h1>

<h1>Add Display specs</h1>

<h1>Add Event specs</h1>

<h1>Return back to completing the Acceptance</h1>

<h1>Major aspects we covered</h1>

<h2><span class="caps">HTML </span>traversing</h2>


<ul>
<li>I want to program akin to how I look at the page</li>
<li>I may look for: an element, a style, some content or a relationship</li>
<li>then perform an action</li>
</ul>



$(&#8216;div &gt; p:first&#8217;)<br />
$(&#8216;#mylist&#8217;).append(&#8220;<li>another item</li>&#8220;)

<h2>Event handling</h2>


<ul>
<li>I want to look at page and add event at that point</li>
<li>I want to load data (ie xml or json)</li>
</ul>



$(&#8216;div&#8217;).click(function(){<br />
	alert(&#8220;div clicked&#8221;)<br />
})<br />
$(&#8216;div&#8217;).bind(&#8216;drag&#8217;, function(){<br />
	$(this).addClass(&#8216;dragged&#8217;)<br />
})<br />
$(&#8216;#results&#8217;).load(&#8216;result.html&#8217;)<br />
$.get(&#8216;result.xml&#8217;, function(xml){<br />
	$(&#8220;user&#8221;, xml).each(function(){<br />
		$(&#8220;<li>&#8220;).text($(this).text()
			.appendTo(&#8220;#mylist&#8221;))<br />
	})<br />
})

<h2>Functional style</h2>


<ul>
<li>almost everything in jQuery are JQuery objects</li>
<li>that returns an object</li>
<li>every method can call a jQuery object</li>
<li>that means you can chain</li>
<li>plus I want it to be short code</li>
</ul>



<p>$(&#8216;<story>&#8216;)<br />
	.addClass(&#8216;indent&#8217;)<br />
	.addClass((idx == 4) ? &#8216;scenario&#8217; : &#8221;) <br />
	.text($(this).attr(&#8216;Prefix&#8217;) + &#8216; &#8216; + $(this).attr(&#8216;Text&#8217;))<br />
	.append($(&#8216;<result>&#8216;).text(&#8220;a child piece of text&#8221;)<br />
		.click(function(){ $(this).addClass(&#8216;click&#8217;)}))	<br />
	.appendTo(results)</p>

<h2>Plugin architecture</h2>


<ul>
<li>drop in a widget (including my own)</li>
<li>then combine, extend</li>
<li>help understand customisation</li>
<li>basically just work</li>
</ul>



<p>$(&#8216;#tree&#8217;).treeview();<br />
$.ajax({<br />
	url: &#8216;/update&#8217;,<br />
	data: <a href="http://+$('#name').val()">name</a>,<br />
	type: &#8216;put&#8217;,<br />
	success: function(xml){<br />
		$(&#8216;#flash&#8217;).text(&#8220;successful update&#8221;).addClass(&#8216;success&#8217;)<br />
	}<br />
})</p>

<h1>With power and simplicity &#8230; comes responsibility</h1>


<ul>
<li>the need to follow conventions<br />
  &#8211; plugins return an array<br />
  &#8211; plugins accept parameters but have clear defaults<br />
  &#8211; respect namespace</li>
<li>the need for structure<br />
 &#8211; test data<br />
 &#8211; min &amp; pack<br />
 &#8211; releases</li>
<li>the need to avoid mundane, time consuming tasks<br />
 &#8211; downloading jquery latest<br />
 &#8211; download jQuery UI<br />
 &#8211; building and releasing packages</li>
<li>needs tests<br />
 &#8211; I use jsspec</li>
</ul>



<p>Sounds like real software development?</p>

<h1>Treat javascript as a first-class citizen</h1>

<p>Give your plugin a directory structure:</p>

<p>/src<br />
  /css<br />
  /images<br />
  query.plugin.js<br />
/test<br />
  spec_plugin.js<br />
  acceptance_plugin.js<br />
  specs.html<br />
  acceptance.html<br />
/lib<br />
 /jsspec<br />
 jquery.min.js<br />
 jquery-ui.js<br />
 /themes<br />
   /base<br />
example.html<br />
Rakefile<br />
History.txt<br />
<span class="caps">README.</span>txt</p>

<h1>Generate your plugin boilerplate code</h1>

<p><a href="http://github.com/toddb/jQuery-Plugin-Generator">jQuery Plugin Generator</a> <br />
* gem install jquery-plugin-generator</p>

<p>(function($) {<br />
  $.jquery.test = {<br />
                <span class="caps">VERSION</span>: &#8220;0.0.1&#8243;,<br />
                defaults: {<br />
                        key: &#8216;value&#8217;<br />
                }<br />
        };</p>

<p>        $.fn.extend({<br />
          jquery.test: function(settings) {<br />
      		settings = $.extend({}, $.jquery.test.defaults, settings);<br />
      		return this.each( function(){<br />
        			self = this;<br />
         			// your plugin</p>

<p>      				})<br />
                }<br />
        })<br />
 })(jQuery);</p>

<h1>Use a build tool to do the &#8230; ah &#8230; building</h1>

<p>rake acceptance            # Run acceptance test in browser<br />
rake bundles:tm            # Install TextMate bundles from <span class="caps">SVN </span>for jQuery and&#8230;<br />
rake clean                 # Remove any temporary products.<br />
rake clobber               # Remove any generated file.<br />
rake clobber_compile       # Remove compile products<br />
rake clobber_package       # Remove package products<br />
rake compile               # Build all the packages<br />
rake example               # Show example<br />
rake first_time            # First time run to demonstrate that pages are wor&#8230;<br />
rake jquery:add            # Add latest jquery core, ui and themes to lib<br />
rake jquery:add_core       # Add latest jQuery to library<br />
rake jquery:add_themes     # Add all themes to libary<br />
rake jquery:add_ui         # Add latest jQueryUI (without theme) to library<br />
rake jquery:add_version    # Add specific version of jQuery library: see with&#8230;<br />
rake jquery:packages       # List all packages for core and ui<br />
rake jquery:packages_core  # List versions of released packages<br />
rake jquery:packages_ui    # List versions of released packages<br />
rake jquery:versions       # List all versions for core and ui<br />
rake jquery:versions_core  # List jQuery packages available<br />
rake jquery:versions_ui    # List jQuery UI packages available<br />
rake merge                 # Merge js files into one<br />
rake pack                  # Compress js files to min<br />
rake package               # Build all the packages<br />
rake recompile             # Force a rebuild of the package files<br />
rake repackage             # Force a rebuild of the package files<br />
rake show                  # Show all browser examples and tests<br />
rake specs                 # Run spec tests in browser</p>



<h1>Testing &#8230; acceptance and specs</h1>


<ul>
<li>specs: <span class="caps">BDD </span>style &#8211; <span class="caps">DOM </span>traversing and events</li>
<li>acceptance: tasks on the <span class="caps">GUI </span>with the packaged version (minified or packed)</li>
<li>these both server as good documentation as well</li>
<li>plus, you have demo page baked in!</li>
</ul>



<h1>Compiling and packaging</h1>


<ul>
<li>Compiling javascript &#8230; hhh? &#8230; yes, if you minify or pack your code</li>
<li>gzip compression with caching and header control is probably easier though</li>
<li>packed code is <span class="caps">HARD </span>to debug if it doesn&#8217;t work</li>
</ul>



<h1>Now you are ready for some development</h1>








<h1>Different ways to test Javascript</h1>

<p><a href="http://www.slideshare.net/jeresig/understanding-javascript-testing">Understanding JavaScript Testing</a></p>


<ul>
<li>testing for cross-browser issues &#8211; so this is useful if you are building javascript frameworks</li>
<li>Unit &#8211; QUnit, JsUnit, FireUnit, </li>
<li>Behvaiour &#8211; Screw.Unit, <span class="caps">JSS</span>pec, <span class="caps">YUIT</span>est, </li>
<li>Functional with browser launching &#8211; Selenium (IDE &amp; RC &amp; HQ), Watir/n, <span class="caps">JST</span>estDriver, WebDriver</li>
<li>Server-side: Crosscheck, env.js, blueridge</li>
<li>Distributed: Selenium Grid, TestSwarm</li>
</ul>



<h1>Reference</h1>

<p><a href="http://www.gscottolson.com/weblog/2008/01/11/jquery-cheat-sheet/">jQuery CheatSheet</a></p>


<ul>
<li>slide 48: great explanation of <span class="caps">DOM </span>manipulation &#8211; append, prepend, after, bfore, wrap, replace &#8230;</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/08/jquery-bdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluent Configurator &#8211; thoughts on getting a design</title>
		<link>http://blog.goneopen.com/2010/03/fluent-configurator-thoughts-on-getting-a-design/</link>
		<comments>http://blog.goneopen.com/2010/03/fluent-configurator-thoughts-on-getting-a-design/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 05:26:22 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/03/fluent-configurator-thoughts-on-getting-a-design/</guid>
		<description><![CDATA[In a previous post series I wrote about Configuration DSLs &#8211; I&#8217;m now just looking at this from another angle of going back to some reading about the microsoft mechanism itself. A quick note about the previous approach. The configuration is centralised into one Configuration object and then the application has this available. This is [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post series I wrote about <a href="../../2009/06/dsl-part-i-writing-a-fluent-interface-for-configuration-in-c/">Configuration <span class="caps">DSL</span>s</a> &#8211; I&#8217;m now just looking at this from another angle of going back to some reading about the microsoft mechanism itself.</p>

<p>A quick note about the previous approach. The configuration is centralised into one <code>Configuration</code> object and then the application has this available. This is similar to Microsoft approach because we have <code>ConfigurationManager</code> available everywhere. The problem for me is that with <code>ConfigurationManager</code> the central configuration point is the app.config and that is how developers expect the application to work &#8211; working against such conventions is often creates more friction than is necessary.</p>

<p>Therefore, if you can&#8217;t use a (replace the) central configuration object as above, you need to have multiple xml settings. But how? Microsoft has a design time changer &#8211; the app designer. <span class="caps">AFAIK </span>this works when you deploy from your design environment. That is far from ideal and means that you create a build per environment. I often see this often or something that approximates this approach. But it does not lend itself to a build server. <a href="http://www.codevil.com/index.php/2009/05/28/setting-appconfig-for-different-environments/">Here&#8217;s</a> a well documented approach that can work in both design and deploy time with some adjustments as this one is design time only and we would need to implement the same code in the <code>deploy.proj</code> for msbuild </p>

<p>So the next approach which I have used is to update through xml replacements. This is easiest done replacing entire xml files which are includes into the main xml file. This can be done easily at deploy time. The problem is that all environment settings are shipped. In the situation where the package is for the one client &#8211; this isn&#8217;t actually a problem. The question is the switching mechanism to swap over xml files. There is the other issue of reconciling differences between environment settings.</p>

<p>This leads to a solution of having all settings in the same file. This approach is outlined in  <a href="http://www.codeproject.com/KB/cs/CustomConfigurationSectio.aspx">Creating Custom Configuration Section</a> which I mentioned below. This approach could work well for the settings in your application. For example, using a proxy, I hook this up myself with my <code>WebRequest</code>. However, this approach wouldn&#8217;t work for <code>log4net</code> settings. So, we still need a better approach for specifying settings in different environments. </p>

<p>Where I want to head is to write a wrapper that manages writing out the xml from C# configuration. This would allow a management strategy that works with the current approach, but could also work in the first mode too of providing its own configuration references. Because settings are in C# they are hidden unless needed. Using an approach like <a href="http://code.google.com/p/migratordotnet/">migratordotnet</a> we interrogate the dll for the settings and make updates at deploy time. This interrogation can take the form of dry-run, diffs, updates, backups. </p>

<p>Configuration is a complex and has many views. All those view combined often leads to mistakes so we need it to be as simple as possible. Very simple approaches have often resulted in cut-and-paste management &#8211; I think this is simplistic and error prone. As a developer, I understand that for my application I need a way to extend my reach into the production environment and yet give operations enough control for customisation. Because I certainly don&#8217;t want to do overnight support, nor do I want to know the credentials for production systems. </p>

<p>There is a final issue. How do we know what environment we are in? (and what are these called? &#8211; local, build, test, prod) Given windows conventions and mixed in with a little *nix I would go with this:</p>


<ul>
<li>System environment variable &#8211; in C# accessed through a registry key and batch (eg <code>set APP_ENV=Prod</code>)</li>
<li>Process environment variable &#8211; eg passed in via commandline and used in say <code>msbuild</code></li>
<li><code>machine.config</code></li>
<li><code>app/web.config</code> &#8211; I would use this other than it has been update from one of the above (if you are using this it is likely that it was manually set)</li>
</ul>



<p><em>Note:</em> I think that for enterprise type solutions (only one production deployment) we do know about every environment that we are deploying to. If not, these ideas are not for you because you have multiple deployments (customers). To me, this is consumer-type software and requires that installers can manage themselves.</p>

<h2>References</h2>

<h3>[1] &#8211; General about ConfigurationManager</h3>

<p>If you want to learn about configuration then here is the key series by Jon Rista on <a href="http//www.codeproject.com">The Code Project</a></p>


<ul>
<li><a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx">Unraveling the Mysteries of .NET 2.0 Configuration</a></li>
<li><a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration2.aspx">Decoding the Mysteries of .NET 2.0 Configuration</a></li>
<li><a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration3.aspx">Cracking the Mysteries of .NET 2.0 Configuration</a></li>
</ul>



<h3>[2] &#8211; Creating custom configuration sections for environment</h3>


<ul>
<li><a href="http://devlicio.us/blogs/derik_whittaker/archive/2006/11/13/app-config-and-custom-configuration-sections.aspx">App.Config and Custom Configuration Sections</a> </li>
<li><a href="http://www.codeproject.com/KB/cs/CustomConfigurationSectio.aspx">Creating Custom Configuration Section for each environment</a> </li>
</ul>




<ul>
<li>example to provide environment specific settings (dev through to prod) </li>
<li>implementation is for runtime switching</li>
<li>use a custom implementation of AppSettings</li>
<li>uses the machine.config for global settings</li>
<li>an approach that requires a specific implementation and xsd updates. Good example that the current implementation is limited and customisations are complex. </li>
<li>design time checking through xsd (rather than intellisense)</li>
</ul>




<h3>[3] &#8211; using compile/deploy time switching</h3>


<ul>
<li><a href="http://www.codevil.com/index.php/2009/05/28/setting-appconfig-for-different-environments/">Swapping out configs</a></li>
<li><a href="http://weblogs.asp.net/bsimser/archive/2007/01/03/handling-multiple-environment-configurations-with-net-2-0.aspx">Handling Multiple Environment Configurations with .NET 2.0</a></li>
<li><a href="http://www.hanselman.com/blog/ManagingMultipleConfigurationFileEnvironmentsWithPreBuildEvents.aspx">Managing Multiple Configuration File Environments with Pre-Build Events</a></li>
<li><a href="http://www.cptloadtest.com/2007/09/22/Managing-Multiple-Environment-Configurations-Through-NAnt.aspx">Managing Multiple Environment Configurations through NAnt</a></li>
<li><a href="http://brennan.offwhite.net/blog/2007/04/26/post-build-deployments-with-msbuild/">Post Build Deployments with <span class="caps">MSB</span>uild &#8211; using WebDeployment task ReplaceConfigSections</a></li>
</ul>



<h3>[4] &#8211; design time deltas with deploy time switching</h3>


<ul>
<li><a href="http://bloggingabout.net/blogs/olaf/archive/2007/02/18/environmental-overrides-made-it-into-entlib-v3.aspx">Enterprise Library Design Time Deltas</a></li>
<li><a href="http://www.pnpguidance.net/Post/EnvironmentalOverridesEnterpriseLibrary3.aspx">Environmental Overrides in Enterprise Library 3.0</a></li>
<li><a href="http://www.davidhayden.com/blog/dave/archive/2007/03/01/EnvironmentalOverridesEnterpriseLibrary3.aspx">Environmental Overrides in Enterprise Library 3.0 &#8211; Managing Development, Test, Staging, and Production Configurations Made Easy!</a></li>
</ul>



<h3>[5] &#8211; poking files</h3>

* 
<ul>
<li>&#8220;XmlMassUpdate <span class="caps">MSB</span>uildCommunity Tasks&#8221;:</li>
<li>&#8220;XMLpoke in nant&#8221;</li>
<li>&#8220;XMLConfig&#8221;</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/03/fluent-configurator-thoughts-on-getting-a-design/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
