Download this extension from the VS Gallery or get the CI build.
Generates a unit test boilerplate from a given C# class, setting up mocks for all dependencies.
Test frameworks supported:
- Visual Studio
- NUnit
Mock frameworks supported:
- Moq
- AutoMoq
- NSubstitute
- SimpleStubs
Dependency injection modes supported:
- Constructor injection
- Property injection via Unity, Ninject or Grace
Right click an item in Solution Explorer and choose "Create Unit Test Boilerplate" .
This will create a test class in the same relative path as the class in a specified unit test project. All the dependencies are mocked and saved as fields which are created fresh for each test via [TestInitialize].
Each mocking framework has its own pattern.
- Customize the unit test output via templates:
- Supports mocking generic interfaces
- Automatically brings in appropriate using statements
- Applies any user-specific formatting rules to the generated code
- Automatically detects which mocking library and test framework you're using
See the changelog for changes and roadmap. If you'd like to see support for other mocking frameworks like Rhino Mocks or other IoC frameworks, open an issue.
Check out the contribution guidelines if you want to contribute to this project.
For cloning and building this project yourself, make sure to install the Extensibility Tools extension for Visual Studio which enables some features used by this project.