This tutorial provides an overview of the unit testing tools available in Visual Studio 2015.
- [Voiceover] As the course unfolds I'll explore the unit testing tools available in Digital Studio. Here is an overview of what is available. In the new project dialog search for the word unit. In the search results I can see several types of unit testing templates. There's one for testing Windows, one for Windows 8.1, one for Windows Phone, and many more. The point is is each of these templates is configured so that you can create a unit test project and get started immediately without having to add an extra configuration. Visual Studio contains a test menu.
Here's where you can run your unit tests, debug your unit tests, create custom playlists, and this is also where you can open the test explorer window. This window is the main window where you run your unit tests and filter unite tests and work with the test results. It's usually docked to the left side of the screen. Here I can see all of my tests. I have 11 unit tests in this project. I can run all those unit tests by clicking here. I can also group my unit tests and filter them.
Here's one way you can group them. Click on this drop down and group by class. There's a context menu available for your code window. Right-click on this method and I can create a unit test for testing that method. I can also run the unit tests that are affiliated with that method or debug the tests that are affiliated with that method. If I have visual studio enterprise installed I can also create a special kind of test called an IntelliTest. Visual Studio is an extensible IDE so I can also go to the tools menu, open up extensions and updates, go to the online node, and search for the third-party and unit testing framework.
Here I can see some additional extensions I can add to Visual Studio like this top item here, allows me to add a new test project template to the new project dialog. Now when I want to create an in unit project template I get the same configuration setup that I would get if it was an MS test built-in project type. If I do want to use one of the third-party frameworks, I use the nugit package manager to install those frameworks. I'll click on the browse section and then search online this is the xunit nugit package.
If I install this nugit package this means that I can now write my unit tests in xunit. And if I install this xunit_runner.visualstudio then I can also test run those inside the visual studio test explorer. This also works for any unit. Visual studio test explorer can run any unit test framework that has developed an adapter interface for the explorer. As you can see, the unit testing tools are spread throughout the visual studio interface. Up next a look at the unit test project types.
- Examining types of frameworks
- Choosing a naming convention
- Creating unit tests
- Running unit tests with Visual Studio
- Modifying and correcting code
- Handling exceptions
- Installing and using nUnit
- Viewing test results with CodeLens
Skill Level Beginner
Q: This course was updated on 08/22/2017. What changed?
A: New videos were added that cover live unit testing and creating a project with the unit test framework.