Overview of Visual Studio Team System 2010 for Developers (Part 2)

Posted by: Subodh Sohoni , on 8/7/2009, in Category VSTS & TFS (Azure DevOps)
Views: 50656
Abstract: In the first part of this article we have seen some of the features which were present in VSTS 2008 but may have been enhanced in Team System 2010. In this second part we will study two new features which are added in Team System 2010.
Overview of Visual Studio Team System 2010 for Developers (Part 2)
 
In the first part of this article, Overview of Visual Studio Team System 2010 for Developers (Part 1), we have seen some of the features which were present in VSTS 2008 but may have been enhanced in Team System 2010. In this second part we will study two new features which are added in Team System 2010.
1.    Test Impact Analysis: We usually create number of unit tests to ensure that the code that we write is bug free and will fulfil a requirement or part of the requirement. Once the test execution is over, we will checkin both, the code and the test so that the test can be utilized as a Build Verification Test (BVT). These tests can be executed any time that the code is changed and it is desirable to get a notification that an appropriate test needs to be executed when some code is changed. For example I have written three methods in a class library as follows:
C#
      public string Concat(string str1, string str2)
      {
            string ret = str1 + str2;
            return ret;
      }

      public int CountWords(string str)
      {
            int count = CountSpaces(str.ToCharArray());
            return count;
      }

      public int CountSpaces(char[] strArr)
      {
            int count = 0;
            for (int i = 0; i <strArr.Length; i++)
            {
                  if (strArr[i].ToString() == " ")
                  count++;
            }    
            return count;
      }   
VB.NET
Public Function Concat(ByVal str1 As String, ByVal str2 As String) As String
      Dim ret As String = str1 & str2
      Return ret
End Function

Private Sub New(ByVal str As String)
      Dim count As Integer = CountSpaces(str.ToCharArray())
      Return count
End Sub

Private Sub New(ByVal strArr() As Char)
      Dim count As Integer = 0
      For i As Integer = 0 To strArr.Length - 1
            If strArr(i).ToString() = " " Then
            count += 1
            End If
      Next i
      Return count
End Sub
 
For this code unit tests are created in TestProject1 and the test methods are given an additional attribute named TestCategory. We will give it a value
 
C#
‘DemoCat’.
      [TestCategory("DemoCat")]
[TestMethod()]
public void CountWordsTest()
{
        Class1 target = new Class1();
    stringstr = "Hello World!";
    int expected = 1;
    int actual;
    actual = target.CountWords(str);
    Assert.AreEqual(expected, actual);
}

[TestCategory("DemoCat")]
[TestMethod()]
public void ConcatTest()
{
        Class1 target = new Class1();
    string str1 = "Hello";
    string str2 = "World!";
    string expected = "HelloWorld!";
    string actual;
    actual = target.Concat(str1, str2);
    Assert.AreEqual(expected, actual);
}
 
VB.NET
‘DemoCat’. Sub New("DemoCat" ByVal As )
      Dim target As New Class1()
      stringstr = "Hello World!"
      Dim expected As Integer = 1
      Dim actual As Integer
      actual = target.CountWords(str)
      Assert.AreEqual(expected, actual)
End Sub
      <TestCategory("DemoCat"), TestMethod()> _
Public Sub ConcatTest()
      Dim target As New Class1()
      Dim str1 As String = "Hello"
      Dim str2 As String = "World!"
      Dim expected As String = "HelloWorld!"
      Dim actual As String
      actual = target.Concat(str1, str2)
      Assert.AreEqual(expected, actual)
End Sub
Ensure that the unit tests succeed and check-in the code with that of test project. Code which is checked-in is now ready for build. If the build which is executed contains the BVT then it can act as a base for notification of a test execution if that code changes. We need to set certain parameters of the build and the test configuration. We will start by modifying the test run settings by opening the Local.testsettings from solution items. Under the tab of Execution Criteria we can see various data collectors. We will enable the collector named “Test Impact Collector”.

Configuration_Settings

We will check-in this item and create a build definition. Now,we will start the process of build definition creation. Under the Process tab, we will need to set a few parameters.

i.              Set the ‘Projects to Build’ property to appropriate value by browsing tothe .sln file.
ii.             Ensure that ‘Analyze Test Impact’ and ‘Run Tests’ are set to True.
iii.            Set ‘Test Assembly Filespec’ to relative path of the assembly which contains the tests. If you have retained the default name and path of the project then the path which is shown in the help text {**\*Test*.dll) is acceptable.
iv.           Set Test Category to the one which is mentioned in the attribute in the code. In our example it is ‘DemoCat’.
v.            Set the Test Container TestSetting File to ‘Local.testsetting’ by browsing to it.
Test_Settings
Execute the build now for the newly created build definition. Build should succeed and the tests are executed and passed. Code built now will act as a base for test impact analysis. Let us go back to our code and make some changes in it. Lines which are highlighted are changed.
C#
public string Concat(string str1, string str2)
{
    string ret = str1 + “ “ + str2;
    return ret;
}
publicintCountWords(string str)
{
    int count = CountSpaces(str.ToCharArray());
    return count;
}
publicintCountSpaces(char[] strArr)
{
    int count = 1;
    for (int i = 0; i <strArr.Length; i++)
    {
        if (strArr[i].ToString() == " ")
        count++;
    }
    return count;
}
VB.NET
Public Function Concat(ByVal str1 As String, ByVal str2 As String) As String
      Dim ret As String = str1 & “ “ & str2
      Return ret
End Function
Private Sub New(ByVal str As String)
      Dim count As Integer = CountSpaces(str.ToCharArray())
      Return count
End Sub
Private Sub New(ByVal strArr() As Char)
      Dim count As Integer = 1
      For i As Integer = 0 To strArr.Length - 1
            If strArr(i).ToString() = " " Then
            count += 1
            End If
      Next i
      Return count
End Sub
 
Before the code is saved open the Test -> Windows -> Test Impact View window. It should show that there are no tests which are impacted. When we save the change it will show now two tests which are impacted. It is observable that even though the code which is changed is not being directly tested, the test which is indirectly affected is shown as Impacted Test. We can make appropriate changes in the tests and execute the tests by right clicking on the impacted tests and selecting ‘Run Impacted Tests’. If the test passes then it moves into the verified section. If the test fails then it remains in the section of Impacted Tests.

Test_Impact_View
When a test is selected it also shows the ‘Code changes causing impact’ for that test.
 
2.    Historical Debugger: One of the integral features of IDE like visual Studio is ability to debug the code without coming out of the editor as well as without creating any additional code to check the values of variables etc. This ability improves the efficiency of programming and productivity of programmers. To debug a large program, it is common to set some breakpoint at an appropriate location in the program. While executing in the debug mode, the program halts at the breakpoint and then we can check values of the variables at that point of execution. What we cannot evaluate are the values of the variables when statements prior to the breakpoint were executed. We need to set breakpoint further earlier in the program and re-execute that program. This is an inefficient way of debugging and Team System 2010 – Developers provides a more efficient way to do the debugging. It is called Historical Debugger. At any point in time we can break the execution of the application, step through the code and after execution check values of variables, call stack etc. when some earlier statements were executed. By default, the Debug History window shows a simple view where it has collected data for Diagnostic Events only. Diagnostic events are Debugger events like Step through the code, Exception Events, Contextual Events like thread start and Framework events. It does not collect the data of debugger events like ‘Autos at every step’ if we do not step through the code. It just records application events. At this time the Debug History window looks like this:

Debug_History

If we step through the code, data about call stack and autos is collected for each step and the window looks like this:

          Through_Code
We can now go to each step and check values of variables. I had set a value ‘0’ to a variable named count in the constructor of the class and used it in a method. When I stepped through the code I realized that I was getting output 0 since value of that variable was getting set before the function call was made.
Historical debugger is enabled by default. It takes some amount of resources to execute. If we want to conserve even those resources then we can disable it from Tools -> Options -> Historical Debugger -> General. The same tab can be used to collect information of method calls and parameters in addition to diagnostic events.
Options_General
The Advance tab in this dialog box allows us to set the name of the folder where the historic debugger will store the recorded data. This file can be used to do the debugging at a later time. The same tab is used to set the parameters to do the debugging of small functions and to toggle the display of a special gutter which gets added when debugging is going on.
          Options_Advanced
Diagnostic events tab allows us to set the events for which historical debugger will collect the data. This can be overridden at the project level while doing the debugging.
          Options_Diagnostic_Events
Finally the Modules tab allows us to do the historical debugging for selective modules. This can be used to save on the disk space since the historical debugger stores the data in a file for every session in a folder and it can become quite large.
          Options_Modules

Summary: In this article which is Part 2 of the article on Team System 2010 – Developers we have seen two new features. The first one allowed us the better quality of the code by prompting us to do the unit testing of the code with a list of tests which have got impacted due to our code changes. The second feature that we saw improved the productivity of coding by making the debugging process more efficient.

If you liked the article,  Subscribe to the RSS Feed or Subscribe Via Email

  
Subodh Sohoni is a VSTS MVP, MCTS - Microsoft Team Foundation Server - Configuration and Development and also is a Microsoft Certified Trainer(MCT) since 2004.   

This article has been editorially reviewed by Suprotim Agarwal.

Absolutely Awesome Book on C# and .NET

C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.

We at DotNetCurry are very excited to announce the The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).

Organized around concepts, this eBook aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on .NET Standard and the upcoming C# 8.0 too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.

Click here to Explore the Table of Contents or Download Sample Chapters!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Author
Subodh is a consultant and corporate trainer. He has overall 28+ years of experience. His specialization is Application Lifecycle Management and Team Foundation Server. He is Microsoft MVP – VS ALM, MCSD – ALM and MCT. He has conducted more than 300 corporate trainings and consulting assignments. He is also a Professional SCRUM Master. He guides teams to become Agile and implement SCRUM. Subodh is authorized by Microsoft to do ALM Assessments on behalf of Microsoft. Follow him on twitter @subodhsohoni


Page copy protected against web site content infringement 	by Copyscape




Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by Dale on Tuesday, August 25, 2009 6:28 PM
Very informative. By chance is there a projected date when Visual Studio Team System for developers or even Visual Studio 2010 Professional Edition will be released?
                   Thank You

Categories

JOIN OUR COMMUNITY

POPULAR ARTICLES

C# .NET BOOK

C# Book for Building Concepts and Interviews

Tags

JQUERY COOKBOOK

jQuery CookBook