<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Vijay's WebLog</title><link>http://blogs.msdn.com/vijayu/default.aspx</link><description>My adventures in testing...</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Unit Testing Business Logic in .NET RIA Services</title><link>http://blogs.msdn.com/vijayu/archive/2009/06/08/unit-testing-business-logic-in-net-ria-services.aspx</link><pubDate>Tue, 09 Jun 2009 02:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9710926</guid><dc:creator>vijayu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/9710926.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=9710926</wfw:commentRss><description>&lt;P&gt;One of the common tasks that &lt;A href="http://code.msdn.microsoft.com/RiaServices" mce_href="http://code.msdn.microsoft.com/RiaServices"&gt;.NET RIA Services&lt;/A&gt; developers have to undertake is testing their mid tier business logic code. Mid tier code typically uses a data access layer (DAL) like Linq to SQL or&amp;nbsp;Linq to Entities for persisting data. However directly coupling the business logic code to the DAL will pose challenges for unit testing and causes tests to depend on the database. One possible solution to avoid this problem is to adopt the repository pattern and write business logic code to go against repository. &lt;/P&gt;
&lt;P&gt;The following steps demonstrates an implementation of a domain service class using a&amp;nbsp;repository to make it unit testing friendly. The example code uses the&amp;nbsp;.NET RIA services &lt;A href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2387" mce_href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2387"&gt;walkthrough application&lt;/A&gt; as its starting point and is modified to use Linq To SQL as DAL.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;STEP 1:&lt;/STRONG&gt; Create an interface that defines the necessary methods for performing basic CRUD operations on the repository&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict1_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict1_2.jpg"&gt;&lt;IMG title=pict1 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=156 alt=pict1 src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict1_thumb.jpg" width=244 border=0 mce_src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict1_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;STEP 2:&lt;/STRONG&gt; Provide concrete implementation of IRepository for Linq to SQL. This is done by performing the repository operations on Linq to SQL’s DataContext as shown below.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict2_4.jpg" mce_href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict2_4.jpg"&gt;&lt;IMG title=pict2 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=530 alt=pict2 src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict2_thumb_1.jpg" width=405 border=0 mce_src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict2_thumb_1.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;STEP 3:&lt;/STRONG&gt; Implement the DomainService class and use the repository instead directly calling into DAL layer in domain operation implementation.&lt;/P&gt;
&lt;P&gt;The code below&amp;nbsp;implements an Organization DomainService which uses an&amp;nbsp;employee repository&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict3_4.jpg" mce_href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict3_4.jpg"&gt;&lt;IMG title=pict3 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=514 alt=pict3 src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict3_thumb_1.jpg" width=523 border=0 mce_src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict3_thumb_1.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;As you can notice from above code snippet, there are few things that are different from the original walkthrough sample : &lt;/P&gt;
&lt;P&gt;1. OrganizationDomainService doesn't derive from the LinqToEntitiesDomainService, instead it derives from the base DomainService class &lt;/P&gt;
&lt;P&gt;2. OrganizationDomainService has been applied with LinqToSqlMetadataProviderAttribute. This adds Linq To SQL’s type descriptor to our domain service class and enables it to reference the Linq To SQL generated entities (Employee entity in this case).&lt;/P&gt;
&lt;P&gt;3. Query/Update methods now call into Repository methods instead of directly calling DAL’s context methods.&lt;/P&gt;
&lt;P&gt;4. PersistChangeSet method has been overridden to call the Repository’s SubmitChanges method&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;STEP 4:&lt;/STRONG&gt; Write a factory class to create instance of the DomainService class and the repository and register it (in Global.asax.cs). This ensures that our factory method is used for domain service class creation by the framework.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict4_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict4_2.jpg"&gt;&lt;IMG title=pict4 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; WIDTH: 520px; BORDER-BOTTOM: 0px; HEIGHT: 312px" height=326 alt=pict4 src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict4_thumb.jpg" width=520 border=0 mce_src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict4_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Now the app is ready for execution (there is no change required to the client side code of the walkthrough project).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;STEP 5:&lt;/STRONG&gt; Creating unit tests&lt;/P&gt;
&lt;P&gt;For unit testing the domain service methods, all we need to do is write a mock repository that creates an in-memory instance of employees and pass it to DomainService.&lt;/P&gt;
&lt;P&gt;Code below shows creation of&amp;nbsp;a mock employee repository.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict5_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict5_2.jpg"&gt;&lt;IMG title=pict5 style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=279 alt=pict5 src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict5_thumb.jpg" width=445 border=0 mce_src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict5_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;and the unit test code would look something like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict6_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict6_2.jpg"&gt;&lt;IMG title=pict6 style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=474 alt=pict6 src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict6_thumb.jpg" width=499 border=0 mce_src="http://blogs.msdn.com/blogfiles/vijayu/WindowsLiveWriter/UnitTestingbusinesslogici.NETRIAServices_DB33/pict6_thumb.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Completed sample source can be downloaded from &lt;A href="http://code.msdn.microsoft.com/RiaServices" mce_href="http://code.msdn.microsoft.com/RiaServices"&gt;here&lt;/A&gt;&amp;nbsp;(see 'Repository for unit testing sample').&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9710926" width="1" height="1"&gt;</description></item><item><title>Test best practices - Part4</title><link>http://blogs.msdn.com/vijayu/archive/2006/04/19/579164.aspx</link><pubDate>Wed, 19 Apr 2006 20:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:579164</guid><dc:creator>vijayu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/579164.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=579164</wfw:commentRss><description>&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;&lt;FONT size=4&gt;TEST TOOLS AND FRAMEWORK&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;The following section gives best practices for test tools and test framework. The requirement for tools and framework are more than the tests because of the scope of their use (entire team or multiple teams uses it).&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&lt;STRONG&gt;Design Checklist&lt;/STRONG&gt;&lt;BR&gt;You should ask yourself the following questions when you are designing any part of the system.&amp;nbsp;&amp;nbsp; &lt;BR&gt;1.&amp;nbsp;Have you iterated, selecting the best of several attempts rather than the first attempt? &lt;BR&gt;2.&amp;nbsp;Have you tried decomposing the system in several different ways to see which way will work best? &lt;BR&gt;3.&amp;nbsp;Have you approached the design problem both from the top down and from the bottom up? &lt;BR&gt;4.&amp;nbsp;Have you prototyped risky or unfamiliar parts of the system, creating the absolute minimum amount of throwaway code needed to answer specific questions? &lt;BR&gt;5.&amp;nbsp;Have you spiked the system, to convince yourself that the proposed solution is likely to work?&lt;BR&gt;6.&amp;nbsp;Has your design been reviewed, formally or informally, by others? &lt;BR&gt;7.&amp;nbsp;Have you driven the design to the point that its implementation seems obvious? &lt;BR&gt;8.&amp;nbsp;Does the design adequately address issues that were identified and deferred at the architectural level? &lt;BR&gt;9.&amp;nbsp;Is the design stratified into layers? &lt;BR&gt;10.&amp;nbsp;Are you satisfied with the way the program has been decomposed into subsystems, packages, and classes? &lt;BR&gt;11.&amp;nbsp;Are you satisfied with the way the classes have been decomposed into routines? &lt;BR&gt;12.&amp;nbsp;Are classes designed for minimal interaction with each other? &lt;BR&gt;13.&amp;nbsp;Are classes and subsystems designed so that you can use them in other systems? &lt;BR&gt;14.&amp;nbsp;Will the program be easy to maintain? &lt;BR&gt;15.&amp;nbsp;Is the design lean? Are all of its parts strictly necessary? &lt;BR&gt;16.&amp;nbsp;Does the design use standard techniques and avoid exotic, hard-to-understand elements? 17.&amp;nbsp;Overall, does the design help minimize both accidental and essential complexity? &lt;BR&gt;18.&amp;nbsp;Does design make it easy to maintain and extend (high coherency and loose coupling meaning ‘open to extension but closed for modifications’)&lt;BR&gt;19.&amp;nbsp;Are their similar tools or pieces of infrastructure already available in other place (other teams)? Avoid duplication of effort and helps each one to leverage the work done by the others. E.g. Sharing logging infrastructure and base class infrastructure between different tools&lt;BR&gt;20.&amp;nbsp;Does the design take into account the fact that this tool/fx could be of use by others (outside feature area) in the team.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;Unit Testing:&lt;/STRONG&gt;&lt;BR&gt;All test tools and framework must have unit tests written with reasonable code coverage before checking in. After the first check in, the goal is to not have a drop in code coverage % for subsequent checkins. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Static analysis:&lt;/STRONG&gt; &lt;BR&gt;Make sure your tool/framework is fxcop clean before you check-in.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Code review:&lt;/STRONG&gt; &lt;BR&gt;All test tools/framework must be code reviewed by atleast&amp;nbsp;one&amp;nbsp;person&amp;nbsp;before checking in. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=579164" width="1" height="1"&gt;</description></item><item><title>Test best practices - Part3</title><link>http://blogs.msdn.com/vijayu/archive/2006/04/06/570458.aspx</link><pubDate>Fri, 07 Apr 2006 03:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:570458</guid><dc:creator>vijayu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/570458.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=570458</wfw:commentRss><description>&lt;P&gt;&lt;FONT size=4&gt;&lt;STRONG&gt;Adopt different test methodologies (test styles)&lt;/STRONG&gt;&lt;/FONT&gt; &lt;BR&gt;Always consider applying different test styles to your area. Each style is suited for finding specific class of issues and applying different styles gives the maximum ROI for your test effort.&lt;BR&gt;Some of the approaches that have been highly effective in the past are:&lt;BR&gt;1)&amp;nbsp;Creation of tools to dynamically generate test cases.&lt;BR&gt;2)&amp;nbsp;Fuzz tools that morph the input data.&lt;/P&gt;
&lt;P&gt;A&amp;nbsp;good&amp;nbsp;list of different test styles is mentioned in:&lt;BR&gt;&lt;A href="http://www.kaner.com/pdfs/GoodTest.pdf"&gt;http://www.kaner.com/pdfs/GoodTest.pdf&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=4&gt;Ensuring Testability&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR&gt;Design for testability is an important point to be considered that greatly affects the quality of our tests. For all new features coming online test owner should have a testability discussion with the developer before feature implementation. The important point that needs to be considered here is - Can we get to all the functionality we want to test in an easy and efficient manner? &lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;FONT size=4&gt;&lt;STRONG&gt;Reviewing test strategy&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;Feature test plan should describe the ‘test strategy’ that will be adopted and should be reviewed as part of test plan review. Primary purpose of reviewing is to share ideas and foster discussions. &lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;&lt;STRONG&gt;Sharing ideas and information&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR&gt;Strive to share the following as much as possible across teams&lt;BR&gt;•&amp;nbsp;test strategy ideas &lt;BR&gt;•&amp;nbsp;test framework/tools &lt;BR&gt;•&amp;nbsp;Information (e.g. new feature addition) in one area that could also affect other areas.&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=570458" width="1" height="1"&gt;</description></item><item><title>Test best practices - Part2</title><link>http://blogs.msdn.com/vijayu/archive/2006/03/30/565187.aspx</link><pubDate>Thu, 30 Mar 2006 22:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:565187</guid><dc:creator>vijayu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/565187.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=565187</wfw:commentRss><description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=5&gt;Guidelines for testing at the right layer&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Start with the component level tests first&lt;BR&gt;&lt;/STRONG&gt;Always start with the lower level first and then move to the higher level. API testing should be the first to be automated through Unit tests. These tests are easiest to write and most robust of all the test layers as they have the smallest surface area for false failures. Getting test access to the core logic of the component is the key to this strategy and will need some upfront work to investigate ways of hosting your component in isolation. Work with your developers to address this as part of your testability plan. Tests written at this level should provide depth testing for features.&lt;/P&gt;
&lt;P&gt;Pros&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Very easy to write, modify and maintain tests 
&lt;LI&gt;Tests run faster 
&lt;LI&gt;Near zero timing issues 
&lt;LI&gt;High level of coverage&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Cons&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Upfront work to enable component isolation 
&lt;LI&gt;Not a real world environment &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;Object model tests comes next&lt;BR&gt;&lt;/STRONG&gt;These tests are at the higher level than component level tests and are suited for automating the scenarios and integration tests for your feature. &lt;/P&gt;
&lt;P&gt;Pros&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Easier to write, modify and maintain tests compared to UI tests 
&lt;LI&gt;More closer to real world environment&amp;nbsp; 
&lt;LI&gt;Less prone to timing issues&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Cons&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Need to provide testability hook (via private interface) for areas not exposed by public object model (DTE)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;UI tests comes last&lt;BR&gt;&lt;/STRONG&gt;The complexity of interacting via the user interface for testing can quickly dwarf the complexity of verifying the logic being accessed. Furthermore, any changes to the user interface can have a devastating impact on the tests. Hence, avoid testing through UI as much as possible. UI should be tested separately and shouldn’t be used to test the core functionality of the feature (business logic). Write UI tests for testing the UI elements in a feature. Also some of the end to end scenarios should be automated using UI automation as that’s a real simulation of how the customer would be using the product/feature.Wait till UI becomes reasonably stable before starting to automate these tests.&lt;/P&gt;
&lt;P&gt;Pros&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&amp;nbsp;Closest to real world environment and real world usage of the feature&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Cons&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Extremely prone to timing issues 
&lt;LI&gt;Usually causes maintenance nightmare&lt;BR&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=565187" width="1" height="1"&gt;</description></item><item><title>Test best practices - Part1</title><link>http://blogs.msdn.com/vijayu/archive/2006/03/29/564286.aspx</link><pubDate>Wed, 29 Mar 2006 23:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:564286</guid><dc:creator>vijayu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/564286.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=564286</wfw:commentRss><description>&lt;P&gt;Here is the first in the series. Note that some of the terminologies used here are specific to the product we test - Visual C# (part of VisualStudio.Net).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=5&gt;Test strategy &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Choosing the right test strategy is an important step to achieve efficient and robust test automation. The following section describes some of the important methods that teams should consider.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Layered approach to testing&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Depending on the type of interaction between the tests and the system under test, our product can be divided into the following four layers. Choosing the right layer/level of testing at the right time in the product cycle is going to be the key to our team's success.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UI level&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This is the level at which most users interact with the product, through the user interface by working with controls and windows.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Object model level&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;At this level tests interact with the product through the public object model (DTE). At this level the different components that make Visual Studio are still interacting between themselves in the same way as they normally run when the product is handled by a user.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Component level&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;At this level tests interact directly with the component under test. In most cases components will not be running in an environment similar to that of the first two levels and component will be hosted in isolation. &lt;/P&gt;
&lt;P&gt;These tests usually are most robust as they the smallest surface area for false failures.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;API level&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;At this level the tests interact part of a component. These tests are written to test functions and methods of individual pieces of a component in isolation. E.g. Unit tests&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=564286" width="1" height="1"&gt;</description></item><item><title>Back from long winter hibernation</title><link>http://blogs.msdn.com/vijayu/archive/2006/03/29/564275.aspx</link><pubDate>Wed, 29 Mar 2006 23:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:564275</guid><dc:creator>vijayu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/564275.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=564275</wfw:commentRss><description>&lt;P&gt;Hmm, its been a long winter in Seattle this year, which was rainy and chilly than ever before. I am back from my winter hibernation to blog :-) . I am really glad that spring is finally here.&lt;/P&gt;
&lt;P&gt;During this time I have changed the team and I now work in &lt;A href="http://msdn.microsoft.com/netframework/future/linq/"&gt;DLinq &lt;/A&gt;test team (I used to work in C# IDE test team working on Edit and Contine feature).&lt;/P&gt;
&lt;P&gt;One of the things we have been doing in the team is to document the test best practices based on the things we have learnt in the past. The goal is to make this a 'Test Guide' that&amp;nbsp; the whole team uses for their individual testing and to provide guidelines to achieve - effective, efficient and robust test automation.&lt;/P&gt;
&lt;P&gt;I will post the series on this in the next several weeks. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=564275" width="1" height="1"&gt;</description></item><item><title>Testing C# Edit and Continue</title><link>http://blogs.msdn.com/vijayu/archive/2005/10/18/482846.aspx</link><pubDate>Wed, 19 Oct 2005 02:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:482846</guid><dc:creator>vijayu</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/482846.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=482846</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Garamond&gt;As we are getting &lt;a href="http://blogs.msdn.com/somasegar/archive/2005/09/14/465465.aspx"&gt;close &lt;/A&gt;to releasing VS whidbey, I was thinking about my contributions to this release and one of the major item that appeared in the list was testing C# edit and contine (here after EnC). This is one of the primary features I was responsible for testing in whidbey. Then I thought of writing a short summary about how we tested this feature. Below is the result of that exercise.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond size=5&gt;&lt;STRONG&gt;Brief history&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;Sometime in Jan 2004 &amp;nbsp;when we were half way into the whidbey product cycle, &lt;a href="http://blogs.msdn.com/somasegar/archive/2004/10/15/242853.aspx"&gt;decision &lt;/A&gt;was made to provide Edit and Continue feature for C# in whidbey. This was based on the overwhelming feedback from customers asking for EnC for C# and that it was the&amp;nbsp;#1 feature request listed in MSDN feedback. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;EnC is one of those features thats very simple to use but complicated when you get into the details of its design and implementation.It touched&amp;nbsp;the&amp;nbsp;core areas of&amp;nbsp;VS&amp;nbsp;- CLR, Compiler, Editor and debugger, making testing very challenging. However our initial understanding was that&amp;nbsp;since VB already had support for this (in whidbey), &amp;nbsp;it was&amp;nbsp;just a matter of making changes to C# compiler and C# editor to make this happen and the support in CLR and debugger already existed (and tested). Its another matter that this assumption turned out to be incorrect (atleast partially)&amp;nbsp;in the end.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;Intially the test team comprised of&amp;nbsp;me and my collegue Daigo (he blogs in Japanese and can be found &lt;a href="http://blogs.msdn.com/daigoh/"&gt;here&lt;/A&gt;). &lt;a href="http://blogs.msdn.com/santoshz/"&gt;Santosh &lt;/A&gt;joined the team some time later.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond size=5&gt;&lt;STRONG&gt;Test strategy&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond size=4&gt;&lt;STRONG&gt;&lt;U&gt;Quality metric&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;We started of by coming up with the quality metric that would help us drive our testing efforct. These are the two primary attributues we wanted to target:&lt;/FONT&gt;&lt;FONT face=Garamond&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;&lt;EM&gt;Stability&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;EnC should reliably succeed or fail.&amp;nbsp; If EnC does not succeed, the user should always be able to resume the original debugging session.&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Garamond&gt;However, when the original debugging session is resumed, code changes will remain.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;&lt;EM&gt;Accuracy&lt;/EM&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;EnC should accurately reflect supported code changes in the new executable image, while maintaining the purity of the rest of the image.&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Garamond&gt;The new image should be accurately reflected in the resumed debugging session.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT size=4&gt;Pieces making up EnC&lt;/FONT&gt;&lt;/U&gt; &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;After talking to developers about the different components making up this feature and the details about their&amp;nbsp; inner workings we came up with the following breakup list that made up EnC:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Rude edit detection:&lt;/STRONG&gt; Feature that detects disallowed edits during EnC. This feature is implemented by C# editor&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Local mapping:&lt;/STRONG&gt; Feature that enables tracking local variables (moving, adding, removing locals) during EnC. This feature is implemented by compiler&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;UI interaction:&lt;/STRONG&gt; All the UI elements associated with EnC such as displaying of&amp;nbsp;rude edit squiglees, readonly markers , error dialogs, etc. This feature is implemented by editor and debugger.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;IP remapping:&lt;/STRONG&gt;&amp;nbsp; Feature that calculates and resets the instruction pointer(IP) to the next active statement during EnC. This feature is implemented by debugger. &lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Line mapping:&lt;/STRONG&gt;&amp;nbsp; Feature that calculates and tracks the movements of statements in the program being debugged during EnC. This feature is implemented by debugger.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;FONT face=Garamond&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT size=4&gt;Approach&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;Once we had the list of sub features making up the overall EnC feature, our next task was to come up with the approach to actually test these pieces individually and also test the feature as a whole. Below list kind of summarized the approach:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Identifying the high risk areas:&lt;/STRONG&gt;&amp;nbsp;We focussed our initial&amp;nbsp;testing on&amp;nbsp;the new code added to support C# EnC. This mainly was rude edit detection, local mapping and line mapping. There were limited modifications to other pieces and was'nt very significant.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Data driven testing:&lt;/STRONG&gt; We used this methodology which is ideal when you have a lot of different data values that you wish to exercise the feature with but where the sequence of steps to execute is pretty much identical. This required some upfront investment on comeup with the test framework but once its up and running, automating the tests was extremely fast.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Testabilty:&lt;/STRONG&gt; We got our developers to provide testabiltiy&amp;nbsp;hooks in the product that made testing higly productive and tests more reliable&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Reuse existing infrastructure:&lt;/STRONG&gt;&amp;nbsp;For the common code, we reused the already written tests (which were already automated) for VB which helped us increase our coverage quickly.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Exploratory testing:&lt;/STRONG&gt; Adoped directed exploratory testing to test the&amp;nbsp;integration scenarios (ie. test EnC the way users would do). This helped us find some really good issues early on in the product cycle.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Stress testing:&lt;/STRONG&gt; We invested good amount of time to come up with stress tool and do stress testing. This&amp;nbsp;mainly comprised (among other things) of&amp;nbsp;determining the upper limit on&amp;nbsp;the number of edits that could be made in a single EnC session. This helped us identify some criticial performance bottlenecks in our implementation which&amp;nbsp;got eventually fixed.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;&lt;STRONG&gt;Effective use of Code coverage:&lt;/STRONG&gt; We used&amp;nbsp;code coverage regularly to identify the test holes and beef up our automation coverage &lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Garamond size=4&gt;&lt;STRONG&gt;&lt;U&gt;Lessons learnt&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;Using diverse methods of testing ('test styles') gives best results&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;Close and constant&amp;nbsp;interaction with the developers helps to keep the crucial two way&amp;nbsp;feedback going&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;Whitebox testing is extremely effective and helps is identifying the right 'targets' for testing&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;Reusing existing tools and infrastructure&amp;nbsp;makes testing more productive&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Garamond&gt;Testing &lt;STRONG&gt;!=&lt;/STRONG&gt; Automation. Its just one of the aspects of overall testing&amp;nbsp;and not an end in itself.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;FONT face=Garamond&gt;
&lt;P&gt;Cheers!&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=482846" width="1" height="1"&gt;</description></item><item><title>C# Edit and Contine: Rude edits</title><link>http://blogs.msdn.com/vijayu/archive/2005/10/13/480784.aspx</link><pubDate>Thu, 13 Oct 2005 23:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:480784</guid><dc:creator>vijayu</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/480784.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=480784</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Georgia&gt;Edit and contine was one of the top features added in whidbey release&amp;nbsp;for C#.&amp;nbsp; Edit and continue is the ablity to modify code and contine with execution while debugging the program.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia&gt;&lt;STRONG&gt;Types of edits/changes supported&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia&gt;There are few restrictions to the types of edits that are permitted during Edit and contine. The restrictions exist mainly due to technical reasons than anything else.&amp;nbsp;The edits are primarily restricted to within method bodies.&amp;nbsp;There are few changes&amp;nbsp;within method bodies that are not permitted and to apply those changes you&amp;nbsp;have&amp;nbsp;to stop debugging and start&amp;nbsp;over again.&amp;nbsp;These unsupported edits are termed as 'Rude edits'. These are notified to&amp;nbsp;the&amp;nbsp;user&amp;nbsp;by &lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Georgia&gt;populating error description in the error list&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Georgia&gt;displaying squiglee and tooltip with error description&amp;nbsp;at the begining of the code block which has rude edit&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Georgia&gt;For a complete list of unsupported changes for C#&amp;nbsp;see &lt;A href="http://msdn2.microsoft.com/en-us/library/ms164927"&gt;here &lt;/A&gt;. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia&gt;Let me know your feedback on the unsupported changes and things you would like to see supported in the future.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia&gt;Cheers!&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=480784" width="1" height="1"&gt;</description></item><item><title>Introduction</title><link>http://blogs.msdn.com/vijayu/archive/2004/01/28/64150.aspx</link><pubDate>Thu, 29 Jan 2004 03:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:64150</guid><dc:creator>vijayu</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/64150.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=64150</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Garamond&gt;Now that I have posted my first ever&amp;nbsp;blog, I&amp;nbsp;will introduce myself. My name is Vijay Upadya and I work in C# QA team. I have been in this team for the past 4.5 years (was in C++ team before the inception of C#).&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Garamond&gt;In my spare time, I&amp;nbsp;love watching (and playing) cricket and volleyball.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=64150" width="1" height="1"&gt;</description></item><item><title>My first blog</title><link>http://blogs.msdn.com/vijayu/archive/2004/01/26/63224.aspx</link><pubDate>Tue, 27 Jan 2004 04:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:63224</guid><dc:creator>vijayu</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/vijayu/comments/63224.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vijayu/commentrss.aspx?PostID=63224</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Georgia&gt;This is my first ever blog post and am excited to be part of the elite club of bloggers !!! &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=63224" width="1" height="1"&gt;</description></item></channel></rss>