Eric Hexter's Blog

Where the rubber meets the road

  Home  |   Contact  |   Syndication    |   Login
  26 Posts | 0 Stories | 1 Comments | 4 Trackbacks

News

View Eric Hexter's profile on LinkedIn

Tag Cloud


Article Categories

Archives

Post Categories

.Net

Commerce Server

Hexter

TDD

Tuesday, June 24, 2008 #

 

I have been really busy between starting as a Principal Consultant for Headspring Systems and a long awaited vacation.  I am just
catching up on some blog posts.

My Silverlight Unit Testing session at the Austin Code Camp 2008 went really well.   The source code and presentation is available for download here.
I got some great feedback and look forward to being able to speak on the topic some more!

 

I wanted to formally thank John Teague for all of his hard work organizing the code camp.  With a new baby at home there was no way I could have organized
it this year so I was happy to have John pull it together while I was able to focus on sponsorships and swag.  I think it was a great event and I will have a retrospective
with John so that we can share all that we have learned about running a camp as well as how to successfully hand off the execution from one person to the next.
I think there is more value in being able to grow a community where we have more leaders who can execute these types of events and I believe we have some
great lessons to share.


There is some great material for all of the code camp sessions on our code camp source repository.  Please check it out here.

 

Subscribe to my feed here http://feeds.feedburner.com/EricHexter


Sunday, June 08, 2008 #

ok..  So Silverlight Beta 2 was released on and it has some great new features. But what is the story about testing...?


1 Jeff Willcox blogged about a small change you will need to make in order to use the existing testing framework. It is
essentially adding a cast to the initial startup code for the testing framework.  He also posted new C# and VB.net project
and item templates. He also hinted that there will be a new release of the test framework and some samples of integration
with a Continuous Integration server.  I am excited about that.  I have some prototypes that were half baked to do this,
I just have not had any time to make it usable.

 

2. The one feature that I am happy to see is the UI Automation (UIA) support. The UIA will make test driving the UI and
producing a true end-to-end test possible with a well documented and supported API.  Accessibility is supported in WPF
so there are some controls that implement these features in this latest release of silverlight. UI Automation has all the hooks to allow
testing tools to drive an application through the U.  Reference http://en.wikipedia.org/wiki/Microsoft_UI_Automation 

The best part about silverlight supporting UIA is that a number of people have already paved the way by testing WPF using
this  API... http://blogs.msdn.com/llobo/archive/2007/09/06/testing-using-wpf-ui-automation.aspx 

Once again I think ThoughtWorks leads the way with their open source project http://www.codeplex.com/white.  Looking at
the getting started page, I am excited to see how easier their helper "core" library integrates with nunit.... What more could I ask for?

 

As I upgrade my previous samples to the Beta 2 Framework and experiment with the White project I will have some posting coming soon.

 

Happily Testing

Eric Hexter


Monday, April 21, 2008 #

Now that we have a working test that can make the proper assertions, the next step is to make the test easier to understand.  First, here is the existing test.

FluentUiTest

The test is loaded with infrastructure code that helps execute the asynchronous calls with the testing framework. This does not help the readability of the tests.  More than half of the code in this methods are helper methods and plumbing.  This is far from ideal.  Another approach to this would be to use a fluent interface that abstracts the plumbing code and leaves a test that is easier to comprehend.

 

FluentUiTest

In this code you will see the UiTestHelper class which hides more of the magic EnqeueXXXX calls to the SilverlightTest base class. This class also hides the code needed to add/remove the control to the test surface as well as call the TestComplete method.  This approach is less complicated and as a result allows for easier comprehension when you need to come back and change the code or the tests later in the project.  The tests are doing the exact same work and making the same assertion. 

 

Subscribe to this feed: http://feeds.feedburner.com/erichexter

 

The code for this project is located here : http://erichexter.googlecode.com/svn/trunk/EndToEndSilverlightDemo


The Silverlight testing framework was recently released and shows some great potential for being
a first class application platform. For more information about the test framework see this post from
Jeff Wilcox.
To start off I choose to use a code sample that had some complexity in it.  Brad Abrams just posted 
a Silverlight walk
End-to-End Data Centric Application with Silverlight 2. This seemed like a good
sample to use, since the post did not consider how to test the code.
Step 1:  Add a test project and test class. 
After the installing the assemblies and project templates, add a new unit test project to the solution.
Change the test class to inherit from SilverlightTest.
The following code demonstrates a simple integration test.
This test does the following: 
  • Instantiates the page.
  • Clears the local storage.
  • Adds the page to the Test framework TestSurface.
  • Enters the letter s into the text box.
  • Clicks the search button.
  • Verifies that 9 products are displayed in the DataGrid.
  • Removes the page from the TestSurface.

Here is the code for the test class:
   1:      [TestClass]
   2:      public class The_data_page_should_load:SilverlightTest
   3:      {
   4:          
   5:          [TestMethod]
   6:          public void When_searching_for_products_starting_with_s_nine_products_should_be_displayed()
   7:          {
   8:              EndToEndSilverlightDemo.Page pageUnderTest = new EndToEndSilverlightDemo.Page();
   9:              IPageTestDriver testDriver = pageUnderTest;
  10:              testDriver.ClearLocalStorage();
  11:              this.Silverlight.TestSurface.Children.Add(pageUnderTest);
  12:              testDriver.TypeSearchPrefix("s");
  13:              testDriver.ClickSearchButton();
  14:              Assert.AreEqual(9,testDriver.DisplayedProductRows);
  15:              this.Silverlight.TestSurface.Children.Remove(pageUnderTest);
  16:          }
  17:      }
 
Here is the Test Driver interface:
   1:  public interface IPageTestDriver
   2:     {
   3:         void TypeSearchPrefix(string searchPrefix);
   4:         void ClickSearchButton();
   5:         int DisplayedProductRows { get; }
   6:         void ClearLocalStorage();
   7:         bool WebserviceHasReturnedData();
   8:     }
Here is the portions of the Page class that implement the IPageTestDriver interface. It is a good idea to 
hide the complexity of the Page classes internal controls from the test class. This is equivalent to
creating a Test Fixture in other frameworks.

   1:          void IPageTestDriver.TypeSearchPrefix(string searchPrefix)
   2:          {
   3:              this.txtProductString.Text = searchPrefix;
   4:          }
   5:   
   6:          void IPageTestDriver.ClickSearchButton()
   7:          {
   8:              this.Button_Click(this.btnOne,null);
   9:          }
  10:   
  11:          int IPageTestDriver.DisplayedProductRows
  12:          {
  13:              get { return (new List<object>((IEnumerable<object>) this.dataGridResults.ItemsSource)).Count; }
  14:          }
  15:   
  16:          void IPageTestDriver.ClearLocalStorage()
  17:          {
  18:              settings.Clear();
  19:              settings.Save();
  20:              dataGridResults.ItemsSource = null;
  21:          }
  22:   
  23:          bool IPageTestDriver.WebserviceHasReturnedData()
  24:          {
  25:              return dataGridResults.ItemsSource != null;
  26:          }
  27:      }
 
Now run the test and everything is good right?  Not so.  But why is that?

sl-test-failed

The test has failed because the application is making an Asynchronous call to the web service.  This means
our test runs and completes before the remote call to return data can complete and load the data into the data grid.
 

Solution:  Use the Asynchronous features of the test framework.

The framework provides the functionality to be able to drive unit tests in an async fashion.  This allows the
test to run and wait for a condition to be met before proceeding.  In this case on line 10 the EnqueueConditional
call waits until the helper method returns true before the test proceeds with the next call.
   1:          [TestMethod,Asynchronous]
   2:          public void When_searching_for_products_starting_with_s_nine_products_should_be_displayed_async()
   3:          {
   4:              EndToEndSilverlightDemo.Page pageUnderTest = new EndToEndSilverlightDemo.Page();
   5:              IPageTestDriver testDriver = pageUnderTest;
   6:              testDriver.ClearLocalStorage();
   7:              this.Silverlight.TestSurface.Children.Add(pageUnderTest);
   8:              EnqueueCallback(() => testDriver.TypeSearchPrefix("s"));
   9:              EnqueueCallback(() => testDriver.ClickSearchButton());
  10:              EnqueueConditional(testDriver.WebserviceHasReturnedData);
  11:              EnqueueCallback(() => Assert.AreEqual(9, testDriver.DisplayedProductRows));
  12:              EnqueueCallback(() => this.Silverlight.TestSurface.Children.Remove(pageUnderTest));
  13:              EnqueueTestComplete();
  14:          }
 
And the results?....
sl-test-passed

The test passes and verifies the full remote call to the web service as well as getting the data back into the user interface.
Pretty cool?  This sample demonstrates that it is possible to test drive the user interface.  The code to do so is far from
being readable and comprehendible.  The next post in this series will address the readability of the testing code and put a
fluent interface around the ugly Enqueue method calls. 

 

The source code for this sample is available here; http://erichexter.googlecode.com/svn/trunk/EndToEndSilverlightDemo/EndToEndSilverlightDemo/ 


Sunday, April 20, 2008 #

Working with the Silverlight testing framework the last three weeks has been interesting.  I ran into a crazy intermittent bug which drove me made for about 2 hours.  The usercontrol that I was adding to the TestSurface would be visible about 50% of the time when running my tests. The test would still run and I could hear the audio portion of the videos that were playing as part of an integration test, but the Controls were not visible on the test surface. All I could see was the blank test surface and the testing framework status on the right side of the test runner.

 
After resorting to reflector on the test framework I found that the TestSurface is a Grid control.  That got me to think that since my controls parent control is also a Grid control that maybe the nested grids are just having some sort of issue.  I ended up solving the problem by Adding my controls to a Canvas control and adding the Canvas instance to the TestSurface.  Code as follows......


Subscribe to this feed: http://feeds.feedburner.com/erichexter 

si-testing-testsurfacebug

 

This solved my problem... The issue is not with the test framework as much as the silverlight runtime.  It is still beta so what do you expect?

More posts on the test framework, both unit testing and integration testing, to come soon.

 

Additional Info: 

For more information about the silverlight testing framework see: http://www.jeff.wilcox.name/2008/03/31/silverlight2-unit-testing/


Saturday, April 19, 2008 #

There was a new source code release of the Asp.Net MVC framework .  We just got the MVC Contrib project upgraded to work against the new release.

You can find the release here.

 

First I would like to thank Jeremy Skinner for his hard work upgrading the release!

 

Here is what changed in the release:

  • Upgraded to the 0416 Source Code drop of ASP.NET MVC.
  • Moved most of ConventionController's logic into ConventionControllerActionInvoker.
  • ControllerDescriptor now only treats methods that return an ActionResult as a valid action.
  • Moved the filters implementation more in line with the implementation in ControllerActionInvoker.
  • Removed the ReturnBinders implementation. The same result can be achieved by using custom ActionResults.
  • Introduced XmlResult to replace XmlReturnBinder.
  • Added RenderText and RenderXML methods to ConventionController.
  • TestControllerBuilder no longer proxies controllers or captures renderview/redirect calls

 

Keep up to date by subscribing to http://feeds.feedburner.com/EricHexter

 

Do you twitter?  You can follow the project on twitter here: http://twitter.com/mvccontrib


Sunday, March 30, 2008 #

I started working with sandcastle to generate api documentation for the Asp.Net MVC - MvcContrib project (http://MvcContrib.org).  I wanted to get some feedback as to how useful the general API Namespace/Class listings are. Below are two of the outputs of the documentation. I encourage you to take a quick look at it so that you can provide feedback.


To Subscribe to this RSS feed use this url:
http://feeds.feedburner.com/EricHexter


Here is an html versions that the project could host online.

http://mvccontrib.googlecode.com/svn/trunk/Documentation/Help/Index.html

Here is a CHM help file.  To view this you will need to Save As, than goto the file properties and click Unblock.  If you do not unblock the file you will see the navigation tree, but all of the content will display a page not found error.

http://mvccontrib.googlecode.com/svn/trunk/Documentation/Help/MvcContrib-Api-Documentation.chm

Questions I need feedback on:

  1. Does having the Namespaces and classes browsable in this format provide and value as a user of the mvccontrib project? 
  2. If all of the feature documentation from the CodePlex wiki was included in the help file would that make a difference to the value that this documentation provides? (The wiki docs are located here: http://www.codeplex.com/MVCContrib/Wiki/View.aspx?title=Documentation&referringTitle=Home)
  3. Is there a better way to provide general api documentation, do you have some examples of something you like?

 

Please provide feedback to this discussion thread. http://groups.google.com/group/mvccontrib-discuss/browse_thread/thread/34431f585a5da6c3


Wednesday, March 26, 2008 #

I thought I would take a small moment to introduce myself and give some context around my opinions.

I have been developing software professionally for 12 years in consulting, product development, corporate IT, premium Brand web sites and e-commerce.  I until recently worked for a well known golf equipment company as the Director of eCommerce Technology.  In this role I have worked on a number of ecommerce sites and have learned a great deal about online retail for both new and used products.  I have learned a lot about online marketing and order fulfillment.  It has been a great experience and has really added to my previous experiences working for manufacturing companies.

I just started a new job this week.  I am working in the role of Technical Architect for Ascentium.  I am very excited about the company in terms of culture and opportunities. More to come on this in the future.

I primarily use Microsoft .Net technologies and the Microsoft application stack (IIS, ASP.Net, Sql server).  I had the unfortunate experience to develop, maintain, support, and bring back to life web site based on Microsoft Commerce Server 2002.  This led me to developing some skills in running command line debuggers on production servers and analyzing User Mode memory dumps to help facilitate conversations with the Commerce Server support team about their use of COM and unmanaged code in a managed domain. If you ever meet me in person I could go into great deal about this.

I am a huge advocate of agile project management and software engineering practices.  I have learned the hard way that writing un-testable tightly coupled code gets you no where fast.  In fact, that type of code usually keeps one in the same spot unable to change and adapt software to the ever changing needs of the business that uses said software.

I am very active in the Austin .Net Users group. I am one of three directors that helps run the group.  I ran the 2007 code camp, which was a great success.  I am acting as an advisor and leading a hand in the 2008 code camp.  Many thanks to John Teague for taking on the 2008 code camp.  I have some new family commitments that just made running this camp unrealistic for me.  So I am glad to help pass the torch.  I have spent many phone calls and emails with user group leaders across the South Central district helping them understand how to run Code Camps and events, using what I learned from my experience.  I have spoken to User Groups and at the Code Camp as well.  My primary focus is around web site operations, deployment, and web farm management. 

I have been actively working on the following Open Source Projects:

MvcContrib  - This is a project that fills in the gaps of the upcoming ASP.Net MVC framework.  There are many contributors and I am happy to be part of this project.

Tarantino - This is a project that has pulled together some libraries and utilities to facilitate application development and deployment.  The features that I am fond of is the Database Change Management tools, web farm management, and application deployment tools.  Kevin Hurwitz is the primary developer on this project and since he is not blogging I have encouraged his work on this and have been pitching in and really pushing to get some solid documentation in place so that the project can be easily picked up and used to help developer work less on infrastructure.

TDD-Generator - This is a pet project that I am still working out.  It is a Visual Studio addin that generates Test,Interface, & Class files with a few keystrokes.  I found that Visual Studio makes it very difficult and to do things the right way.  The intent of this project is to make creating the code files used in TDD easier and with less friction than developing using the Project-Add  New file metaphor that is built into Visual Studio.  Here is a screen cast which demonstrates the addin http://erichexter.googlecode.com/svn/trunk/TestFirstGenerator/docs/ScreenCast.htm


I just released the latest build in binary and source code format on CodePlex.

What's new in this release?
The following items are changes from the previous release:

Revision: 275
- corrected some warnings/errors.
- added ViewDataExtensions. This brings the functionality of the smartbag to ViewData.
- now, we have easy adding and getting to and from ViewData. No more casting, and if you only put a single "Customer" in Viewdata using new Add() method, you just have to Get<Customer>(), and that's it.
Revision: 272
Patch 1018 By:alley Added support for Unity as IoC container.
Revision: 270
Replaced all remaining occurrences of the MVCContrib namespace with MvcContrib.
Rev 267
- the ability to use TestControllerBuilder with controllers that have constructor arguments
- associated unit test

You can download the release here:
https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=MVCContrib&ReleaseId=12005


The documentation for the features in the MvcContrib project are located here:
http://www.codeplex.com/MVCContrib/Wiki/View.aspx?title=Documentation&referringTitle=Home


If you have some cool feature that adds to the MVC framework then contribute and share with the community! Here are details on how to contribute.
http://www.codeplex.com/MVCContrib/Wiki/View.aspx?title=Contribute&referringTitle=Home


Tuesday, March 11, 2008 #

Our source control tree is setup with the projects at the root of our server and each has a separate trunk, tags, and branches.  While this makes it very easy to have a location agnostic build and include all the dependencies in one place for a particular project, this aspect can be painful when you want to checkout the trunk of each project to a new developer machine.  I wrote a little batch file to ease the pain.

Sample Source Control Repository

Project1
   trunk
   tags
   branches

Project2
   trunk
   tags
   branches

ect ...

Batch file to pull checkout all of the trunks.

   1: set svnbin="d:\Program Files\CollabNet Subversion Server\bin\svn.exe"
   2: set svnroot=http://sourceserver:8080/svn/cgi/
   3: %svnbin% list %svnroot%>projects.txt
   4: FOR /F "tokens=1" %%i IN (projects.txt) DO %svnbin% checkout %svnroot%%%itrunk %%i

 

Subscribe to this feed:  http://feeds.feedburner.com/EricHexter


This is pretty easy to modify, simple replace your bin location for subversion executable and update the svnroot to the path to your subversion repository and you are good to go.  The one important gotcha here is that subversion is case sensitive.  I ran into a problem where our repository has some of the trunks starting with a lowercase t and other starting with a uppercase t.  In that case, I just added an additional line 4 with the uppercase Trunk.  That batch file roles on without stopping if there is a mismatch in the case of trunk.


Wednesday, March 05, 2008 #

As part of the Mix 08 conference a new version of the Microsoft MVC framework is available for download.

http://www.microsoft.com/downloads/details.aspx?FamilyId=A9C6BC06-B894-4B11-8300-35BD2F8FC908&displaylang=en

 

The MvcContrib team will be working to get the contrib project up and running on the new version.


Friday, February 29, 2008 #

I just released the latest build in binary and source code format on CodePlex.

The following items are changes from the previous release:

  • Added support for InputImage in FormHelper (new methods FormHelper.ImageButton())
  • Added Password Tag
  • Added support for Password tag in FormHelper (new methods FormHelper.PasswordField())
  • Updated test to maintain 100% on form helper and UI
  • Changed TextArea to use a full Close tag when value is empty instead of a XML tag close ("/>").
  • Fixed UI.Html/FormHelperTester.cs tests to anticipate new results.
  • Patch #882 - tehlike ReturnBinder implementation ported from MonoRail. / Modified tests slightly to reach 100% coverage.
  • Patch #864 - Woil This patch cleans up some of the namespaces from the older MvcTestFramework to the new MvcContrib.TestHelper namespace.
  • Added comments to all of the TestHelper classes which should make them easier to use. Applied with minor modification -
  • Sample test project referenced the Debug directory of MvcContrib.TestHelper, which caused CommitterBuild to fail. Changed to use $(Configuration) instead.
  • Made methods on FormHelper virtual. Fixed the namespace for the ObjectFactoryDependencyResolver, SpringDependencyResolver and StructureMapDependencyResolver - they were under the UnitTests namespace.

You can download the release here:
https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=MVCContrib&ReleaseId=11177


The documentation for the features in the MvcContrib project are located here:
http://www.codeplex.com/MVCContrib/Wiki/View.aspx?title=Documentation&referringTitle=Home


If you have some cool feature that adds to the MVC framework then contribute and share with the community! Here are details on how to contribute.
http://www.codeplex.com/MVCContrib/Wiki/View.aspx?title=Contribute&referringTitle=Home


Monday, February 25, 2008 #

I am relocating from Geeks With Blogs to Los Techies.  You can now find my thoughts here.... http://hex.LosTechies.com

The new RSS feed is: http://www.lostechies.com/blogs/hex/rss.aspx  Subscribe to it now, because I am motivated to get some of my random technical thoughts in written form.


Monday, October 16, 2006 #


Announcing NAnt 0.85.  It has been some time since the release candidate was published, so this update has been a long time coming..  It is oficially released and available for download.

Details here: http://sourceforge.net/forum/forum.php?forum_id=623166

Eric Hexter


Thursday, October 12, 2006 #

Commerce Server 2002 Service Pack 4 has been released.  You can see some details here...

http://blogs.msdn.com/nihitk/archive/2006/10/11/commerce-server-2002-service-pack-4-released.aspx

 

Below is the list of bugs that have been fixed.  This is the reason I hate commerce server.  almost 5 years after its release,  they are still releasing patches for memory issues and other bugs which I consider to be pretty major.  This is a platform that is supposed to be able to run high volume commerce sites.  I think the people who worked on the original code should be embarrassed of the work they produced.

http://support.microsoft.com/kb/924899/ 

 

Eric Hexter