Skip to content
| Marketplace
Sign in
Visual Studio>Tools>MockIt

MockIt

Preview

Yevhen Cherkes

|
73 installs
| (0) | Free
MockIt is a Visual Studio extension that provides a Diagnostic Analyzer and Code Fix Provider for generating mocks for the Moq framework.

Made in Ukraine Stand with the people of Ukraine: How to Help

A Diagnostic Analyzer and CodeFix Provider aimed to automate mocks creating and configuring.

You can use it as a Visual Studio Extension or install as a NuGet package.

For Visual Studio Code you should install a NuGet package and enable Roslyn Analyzers, see Example project.

Additionally, you can configure variable and field name templates.

Quick introduction:

In the Constructor or TestInitialize (SetUp for NUnit) marked method create the instance of your Service Under the Test (SUT).

After that you can see code analysis error and the following suggestions (lightbulbs):

  • to create a constructor without parameters
  • to fill with mocks

Choose "Fill with mocks" - it will create the mocks required for your service and put them into constructor.

Create TestMethod (Test for NUnit) marked method and write here a call of any methods of your SUT.

If SUT's method uses any of injected instances Visual Studio shows you code analysis info.

Choose "Setup mocks with callbacks" or "Setup mocks" - it will setup the mock's methods and calls VerifyAll for each of them.

After that change all default(type) expressions to values you want.

alt tag

This tool has been working well for my own personal needs, but outside that its future depends on your feedback. Feel free to open an issue.

PayPal

Any donations during this time will be directed to local charities at my own discretion.

Privacy Notice: No personal data is collected at all.

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft