microsoft / UnitTestBoilerplateGenerator

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.
MIT License
158 stars 51 forks source link

How to generate NUnit test code? #14

Closed doggy8088 closed 7 years ago

doggy8088 commented 7 years ago

Installed product versions

Description

I was created a NUnit 3 Unit Test project. When I use Unit Test Boilerplate Generator to generate a new test class. It used "Visual Studio Test" by default and I don't know where to configure this extension to use NUnit framework. Is there any document on this?

Steps to recreate

  1. Right click on an C# class file (project item) in the Solution Explorer.
  2. Click "Create Unit Test Boilerplate"

Current behavior

The code always generate "Visual Studio Test" framework code base.

Expected behavior

I was expected to use "NUnit" framework that my project current used.

RandomEngy commented 7 years ago

Thanks for the report. I've got a fix in the pipe for this that will be in the next release

doggy8088 commented 7 years ago

Can I add new "Mock framework" template into options?

image

RandomEngy commented 7 years ago

No, NUnit is a test framework, not a mock framework. I'll have this bug fixed in the next release, hopefully. Just sit tight.

doggy8088 commented 7 years ago

I know NUnit is not mock framework. I mean I want to add more mock framework into this. Is that possible to customize these templates by adding new mock framework into your extension?

RandomEngy commented 7 years ago

You can submit a pull request with your mock framework supported. I gave some advice on it here: https://github.com/Microsoft/UnitTestBoilerplateGenerator/issues/13

doggy8088 commented 7 years ago

Thanks 👍

RandomEngy commented 7 years ago

Should be fixed in 1.5.10.

ianrandell commented 7 years ago

I've just downloaded v1.5.10 and I cannot get it to generate nunit boilerplate. I'm using VS 2017, the project is a csproj-based .NetCoreApp 1.1 with NUnit v3.7.1 and NUnit3TestAdapter v3.8.0-alpha1 nugets. Any ideas?

testJunkie commented 7 years ago

Same here, for .NetCoreApp 2.0, NUnit 3.7.1, Generator 1.5.10, Visual Studio 2017 15.3

RandomEngy commented 6 years ago

In 1.5.12 I fixed an issue with the auto-detect code for .NET Core projects, and added a choice to override the test framework or mock framework when generating the class.