Coder Social home page Coder Social logo

ycherkes / mockit Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 16.51 MB

MockIt is a Diagnostic Analyzer and CodeFix Provider for generating mocks for the Moq framework.

License: Apache License 2.0

C# 99.10% PowerShell 0.90%
mock roslyn-analyzer roslyn-codefix visual-studio-extension mock-automation

mockit's Introduction

I recommend using Unitverse C# Unit Test Generator Visual Studio extension as it supports Mock and NSubstitute and generates full test classes.

MockIt

marketplace marketplace installs nuget downloads

License: Apache 2.0

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:

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

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, Fact or Theory for xUnit) 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.