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

Methods template #37

Closed bartekpokerbartek closed 6 years ago

bartekpokerbartek commented 6 years ago

Installed product versions

Description

Hello in Test Framework (NUnit) and Moq Framework (Moq) I have $TestMethods$ variable in template. Could You please advise how to change how generated functions are built? Can't find anything on how to do that.

For example I mean that function is generated like: `[Test] public void GetNewCardData_StateUnderTest_ExpectedBehavior() { // Arrange var unitUnderTest = CreateService();

        // Act
        var result = unitUnderTest.GetNewCardData();

        // Assert
        Assert.Fail();
    }`

but I want it to look like ie.: `[Test] public void GetNewCardData_StateUnderTest_ExpectedBehavior() { var result = _unitUnderTest.GetNewCardData();

        // Assert
        Assert.Fail();
    }`

Kind regards.

rCartoux commented 6 years ago

Hi,

You should be able to achieve that:

Go to Options > Unit Test Boilerplate Generator > Templates

Select and NUnit and Moq

Set 'Tested object creation format' to empty

Set 'Tested object reference format' to _unitUnderTest

bartekpokerbartek commented 6 years ago

Thanks, for the info, it worked great.

Kind regards.