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: https://feeds.feedburner.com/erichexter

 

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

Silverlight Testing – Part 1 – Testing the untested.