Skip to content
An extension for Visual Studio that generates a unit test boilerplate from a given class, setting up mocks for all dependencies. Supports NUnit, Visual Studio Test, Moq and SimpleStubs.
C# Other
  1. C# 98.6%
  2. Other 1.4%
Branch: master
Clone or download
RandomEngy Added ability to specify extra "using" namespaces to add to the test …

Fixed options dialog closing when pressing Enter on the test method format fields.
Latest commit 428d247 Aug 22, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
SelfTestFiles/Expected Fixed null reference on classes that have attributes on method parame… Aug 14, 2019
.editorconfig Updated .editorconfig to specify tabs Apr 24, 2017
.gitignore Finished self-testing tool. Oct 20, 2017
BeforeScreenshot.png Added ability to specify extra "using" namespaces to add to the test … Aug 22, 2019
OptionsScreenshot.png Cleanup from test method PR Jul 2, 2018
appveyor.yml Update appveyor to VS 2017 image Feb 23, 2018

Unit Test Boilerplate Generator

Build status

Download this extension from the VS Marketplace or get the CI build.

Generates a unit test boilerplate from a given C# class, setting up mocks for all dependencies and test outlines for all public methods.

Test frameworks supported:

  • Visual Studio
  • NUnit
  • xUnit

Mock frameworks supported:

  • Moq
  • AutoMoq
  • NSubstitute
  • SimpleStubs
  • Rhino Mocks
  • FakeItEasy

Dependency injection modes supported:

  • Constructor injection via any IoC framework
  • Property injection via Unity, Ninject or Grace

Right click an item in Solution Explorer and choose "Create Unit Test Boilerplate" .

Before Screenshot

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]. In addition, all public methods on the tested class are set up with a test method outline:

After Screenshot

Each mocking framework has its own pattern.

Other features

  • Customize the unit test output via templates: Go to Options > Unit Test Boilerplate Generator > Templates

Options Screenshot

Supported format tokens documentation

  • 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 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.



You can’t perform that action at this time.