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

Ability to add custom Mock and Test framework templates #35

Closed drobertson123 closed 4 years ago

drobertson123 commented 6 years ago

Installed product versions

Description

Please add an option for custom test frameworks and Mock libraries. It would be wonderful to be able to create our own templates for creation of test classes.

This could also allow people to share templates they have created for special purposes. It seems like your tool is very close to this already.

Expected behavior

Menu > Tools > Options.... Select "Unit Test Boilerplate Generator" Have Option to "Add Template" Select the template file and define what Framework and Mock Library it uses.

Also the ability to add Test and Mock Framework definitions.

Ability to Edit the Test File Contents (already there) Ability to delete entries

RandomEngy commented 6 years ago

You can already customize the templates. Are you asking for a better way to share them around?

drobertson123 commented 6 years ago

I am looking for 2 things.

The first is to be able to define a completely new template and have a way of invoking it. This may include using a Testing library from a list and a Mock library or possibly none of them. The key would be that it implements a template I can define.

In some cases, we want to do basic unit testing. In others, we may want to do tests that are closer to integration testing. Not all testing is the same. Having the ability to create our own templates would be a huge help.

The second thing would be a way to distribute the templates. I would like to share them with our programming group. Another nice thing would be the ability of people to create templates and share them publicly. Possibly templates to help people to test components built on a specific library or things like that.

It feels like you must have some way of defining how the classes are created. Essentially abstract that out into a document that could be added as a new template.

RandomEngy commented 6 years ago

Yes, currently there is only one template per test framework/mock framework combo. I assume you are asking to be able to store multiple templates and name them? Then pick which one you want to use in the "create" dialog?

I was thinking of maybe storing templates in source control so people working on a specific project can see and use them. Was that along the lines you were thinking of in terms of sharing?

As for public sharing, were you thinking of an export to file/import from file function?

drobertson123 commented 6 years ago

I think the source control base storage would be great. That would really work well for my particular needs.

I am not too hung up on the specifics of the import/export. Just some way to exchange templates.

RandomEngy commented 4 years ago

I've added a "Workspace Settings" tab to the options in v2.2.0. You can copy your current settings to a solution-scoped config file, which will automatically be picked up by teammates if it's checked into source control.