Code Monkey home page Code Monkey logo

unittestboilerplategenerator's Introduction

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

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.

Contribute

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.

License

MIT

unittestboilerplategenerator's People

Contributors

randomengy avatar rcartoux avatar

Watchers

 avatar  avatar

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.