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

Support for FluentValidation #33

Closed btastic closed 6 years ago

btastic commented 6 years ago

Description

I really like fluent validations as they give a more descriptive messages when things are going wrong.

Current behavior

Currently the default Assert is used.

Expected behavior

I can decide what asserting library I want to use - I saw a bunch of different asserting libraries, so might be a good start with FluentValidation

Link: https://www.nuget.org/packages/fluentvalidation/

RandomEngy commented 6 years ago

We don't write a lot of Assert statements. Only the Assert.Fail in the stub tests I think.

One workaround would be to remove the $TestMethods$ part in the template and put in your own "starter" test with whatever assert statement you want. Though you'd only get the one test, and not one per public method.

A more general fix might be to add a template for the test method contents, so you could change what's put under the // Assert section. Would also probably need to add a list of namespaces to add in. With those two things you could set it up to whatever validation library you wanted.

btastic commented 6 years ago

Sounds cool! Thanks for the quick response!

RandomEngy commented 5 years ago

In 2.0 the test method code is generated from a customizable template.