Overview [ Documentation]
See also: Notes on Unit Testing with MSTest
Key points:
- Use unit tests as both design documentation and functional specifications.
- Visual Studio installs the Microsoft unit testing frameworks for managed and native code (MSTest).
- Note: MSTest is both a framework and an adapter to that framework.
- Visual Studio Test Explorer also supports 3rd-party adapters to the MSTest framework: xUnit, NUnit, others(?).
Generating Unit Tests and Generating Code
Generating Unit Tests from Existing Code
Visual Studio > Code editor > right-click > Create Unit Tests
The unit test stubs are created in a new unit test projects for all methods of the class.
Generate Unit Tests that Take Multiple Sets of Input
See here.
Generating Code from Unit Tests (TDD)
- In a test method, write a statement that calls a class or method to be generated
- Open the light bulb under the error > Generate type or Generate method