Note: You can also right-click on test results and use the Copy command to copy details to the clipboard. This would be useful when sending an email, for example. The summary view of the failed test run shows that an ArgumentNullException exception occurred during the test run and even provides the stack track at the time of the exception. Note that we can follow links to go directly to the source code for the test or to points within the stack trace. Select the source link to go to the source code for the test method. Figure 15 Navigate to the source of the test method Figure 16 Initial view after navigating to source of the test method Find the line of code that is commented out and un-comment it. Assume that this is the root cause for the failed test. Figure 17 Fixing the root problem of the failed test Press Ctrl+S to save your changes. Right-click on the failed test in Test Explorer and select Run Selected Tests to make sure that the problem is fixed. Figure 18 Running the failed test again to validate fix So far, we have seen how to run all discovered tests, search for specific tests, and group by test outcome. Now let’s take at a few other ways that you can organize and navigate unit tests to make unit testing easier. For some motivational context, remember how long you needed to wait for the coded UI test to complete, and then imagine that there are many more of those. It would be nice if the tests were organized such that you could easily avoid kicking off those tests without having to be careful of the tests that you select. To start with, as of Visual Studio 2012 Update 2, there are a number of useful grouping options. Right-click somewhere within the Test Explorer window and select Group By | Class.
Note: You can also right-click on test results and use the Copy command to copy details to the clipboard. This would be useful when sending an email, for example. The summary view of the failed test run shows that an ArgumentNullException exception occurred during the test run and even provides the stack track at the time of the exception. Note that we can follow links to go directly to the source code for the test or to points within the stack trace. Select the source link to go to the source code for the test method. Figure 15 Navigate to the source of the test method Figure 16 Initial view after navigating to source of the test method Find the line of code that is commented out and un-comment it. Assume that this is the root cause for the failed test. Figure 17 Fixing the root problem of the failed test Press Ctrl+S to save your changes. Right-click on the failed test in Test Explorer and select Run Selected Tests to make sure that the problem is fixed. Figure 18 Running the failed test again to validate fix So far, we have seen how to run all discovered tests, search for specific tests, and group by test outcome. Now let’s take at a few other ways that you can organize and navigate unit tests to make unit testing easier. For some motivational context, remember how long you needed to wait for the coded UI test to complete, and then imagine that there are many more of those. It would be nice if the tests were organized such that you could easily avoid kicking off those tests without having to be careful of the tests that you select. To start with, as of Visual Studio 2012 Update 2, there are a number of useful grouping options. Right-click somewhere within the Test Explorer window and select Group By | Class.
Unit%20Testing,%20Code%20Coverage%20and%20Code%20Clone%20Analysis%20with%20Visual%20Studio%202013.docx