This would look at the code paths for this one unit test. In Visual Studio, to use the code coverage tool, you right click on a test in the Test Explorer and then choose Analyze Code Coverage for Selected Test. I'm feeling pretty good about our project until a coworker, who walks into my office one day and says, "Did you realize we're not testing "our account class?" I could look through the thousands of unit tests in our project to verify that's true, or I could use an automation tool to look at the code coverage path. I'm looking at my tests and they're all passing. In a real application I might have hundreds or thousands of unit test, for this demonstration I'm using a small subset of tests. The code coverage features are available in Visual Studio Enterprise edition only. The more code that is tested in the application, the more thorough your test rests can be. To determine what percentage of your project's code is actually being tested by your unit test, you can use the code coverage feature of Visual Studio. You might notice that the solution name is different in the original video and here in the GIT repository there's also additional solution level folder, but that doesn't impact the example. You can download the zip from the original course, or find the sample in the weekly tips GIT repository. Also, the source code for this video is available in two locations. First, this feature is only available in the Enterprise edition. Before showing the tip, I have some housekeeping notes. I thought I'd revisit this tip on how to discover untested code with code coverage. This tip is from my Visual Studio Essentials Series. I have recorded a lot of tips in my other courses that I think you'll find useful.
0 Comments
Leave a Reply. |