Silverlight Testing – Part 2 – Making the test easier understand.

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

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

About Eric Hexter

I am the CTO for QuarterSpot. I (co)Founded MvcContrib, Should, Solution Factory, and Pstrami open source projects. I have co-authored MVC 2 in Action, MVC3 in Action, and MVC 4 in Action. I co-founded online events like mvcConf, aspConf, and Community for MVC. I am also a Microsoft MVP in ASP.Net.
This entry was posted in silverlight, testing. Bookmark the permalink. Follow any comments here with the RSS feed for this post.