Overview
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
ℹ️ Important
Availability: C#, Visual Studio 2019+
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