GithubHelp home page GithubHelp logo

microsoft / unittestboilerplategenerator Goto Github PK

View Code? Open in Web Editor NEW
158.0 18.0 51.0 1.26 MB

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.

License: MIT License

C# 98.82% HTML 0.77% CSS 0.41%

unittestboilerplategenerator's Introduction

unittestboilerplategenerator's People

Contributors

jessmcanally avatar randomengy avatar rcartoux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unittestboilerplategenerator's Issues

add "Go to Test" context menu item

Installed product versions

  • Visual Studio: Professional 2017 Preview v 15.8.0 Preview 4
  • This extension: V 1.9.10

Description

Please add context menu item in two locations that would take you to the tests.

Expected behavior

Location 1 - Solution Explorer
Right click on the class in Solution Explorer
menu item to "Go to tests"
Opens the Tests Class

Location 2 - Code Editor
Right click on Method or Code in Code Editor
menu item to "Go to test"
Opens the Tests Class at the test method for that method

Incorrect testing framework detected and selected (xUnit)

Installed product versions

  • Visual Studio: 2017 Enterprise 15.9.0
  • This extension: 1.9.10

Description

Extension detects Visual Studio as test framework when xUnit is referenced.

Steps to recreate

  1. Create an xUnit test project
  2. Reference xUnit in the project
  3. Click the extension menu
  4. Dialog shows "Detected: Visual Studio" and selects the Visual Studio test framework
    image

Current behavior

Detects and selects incorrect test framework

Expected behavior

Detect and select the correct test framework

Cannot set the default template

Installed product versions

  • Visual Studio: [example 2015 Professional]
  • This extension: [example 1.1.21]

Description

In general, I need use the template of NSubstitude as the default. But it will always use the template of Moq. And I cannot change it on the options.

Could you consider add to support change the default template to use?

How to generate NUnit test code?

Installed product versions

  • Visual Studio: 2015 Enterprise
  • This extension: 1.5.2

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.

System.InvalidOperationException: Sequence contains no matching element

Installed product versions

  • Visual Studio: 2015 Enterprise w/Update 3
  • This extension: 1.4.3

Description

System.InvalidOperationException: Sequence contains no matching element

Steps to recreate

Not sure as it seems to happen only on some classes even if the class is almost identical to one that work

Current behavior

---------------------------

---------------------------
System.InvalidOperationException: Sequence contains no matching element

   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)

   at UnitTestBoilerplate.CreateUnitTestBoilerplateViewModel.<GenerateUnitTestContentsFromFileAsync>d__20.MoveNext() in C:\projects\unittestboilerplategenerator\src\CreateUnitTestBoilerplateViewModel.cs:line 258

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at UnitTestBoilerplate.CreateUnitTestBoilerplateViewModel.<GenerateUnitTestFromProjectItemSummaryAsync>d__19.MoveNext() in C:\projects\unittestboilerplategenerator\src\CreateUnitTestBoilerplateViewModel.cs:line 162

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at UnitTestBoilerplate.CreateUnitTestBoilerplateViewModel.<<get_CreateUnitTestCommand>b__18_0>d.MoveNext() in C:\projects\unittestboilerplategenerator\src\CreateUnitTestBoilerplateViewModel.cs:line 118
---------------------------
OK   
---------------------------

FR: Control over code generation

Installed product versions

  • Visual Studio: 2015 Enterprise. Update 3
  • This extension: 1.4.5

Description

I am not sure if this might already be possible, but I could not find anything that would indicate it.

I would like to be able to have some control over the generated classes, e.g. a templating feature of sorts. The reason being that there is allot in the Boilerplate that we would remove or replace.

The Boilerplace generate code for Moq, but we use AutoMoq on top so the generated code is completely useless to us, so we would rather that it didn't produce this.

Another thing is that it generates SetUp and TearDown's with instance fields and this is just side-effects waiting to happen, there is also strong opinions against them in general as they tend to make tests more difficult to read as you need to understand not one method but 3 to understand the test it self. (Go read The Art of Unit Testing)...

However, the ability to select a full range of classes and then get test classes generated for all those in the right structure is excellent so if we could preserve that we would like to.

DateTime object in Class Constructor Argument List Generated and Invalid Test Format

Installed product versions

  • Visual Studio: [example 2017 Community]
  • This extension: [example 1.5.2]

Description

I have a class, Student with a constructor having a DateTime object in the argument list.

The extension created these statements:
private Mock mockDateTime;
mockDateTime = mockRepository.Create();

Steps to recreate

  1. Create a simple Class with DateTime as an object in the argument list.
  2. Create a test for the Class
  3. The above error(s) will appear.
    "the type 'DateTime' must be a reference type in order to use it as a parameter 'T' in the generic type or method 'mockfactory.create()'"
    "the type "System.DateTime" must be a reference type in order to use it as parameter 'T'"

Current behavior

The generated statements cannot be copiled.

Expected behavior

Put DateTime directly in the argument list and do not attempt to use moq.

mock object creation fails for objects with generic type parameters

Installed product versions

  • Visual Studio: 2015 Professional Update 3
  • This extension: 1.5.0
  • Mocking Framework: NSubstitute

Description

When using constructor injection with objects whose types have generic type parameters, the BoilerPlate Generator fails to create the mock object. The private member variable is not created, the object is missing from the TestInitialize() method, and the Create method uses the text "TODO" in place of the missing variable.

Steps to recreate

  1. Create a class whose constructor takes an argument with a generic type parameter(e.g. ILogger logger)
  2. Select NSubstitute for mocking framework (other frameworks not tested, so they may be affected as well)
  3. Use the extension to generate boilerplate
  4. observe the missing mock object in the member variable area, the TestInitiaze() method, and the Create method.

Current behavior

See description

Expected behavior

Injected objects utilizing generic type parameters are generated and mocked just like non generic objects.

Doesn't let me choose NSubstitute

Latest VS2017 Community x64. Latest extension. Using .NET Core.

I go to tools and select NSubstitute.
I generate a test class
The test class is for Moq instead of NSubstitute.

Doesn't actually generate NUNit compatible unit tests

Installed product versions

  • Visual Studio: Visual Studio 2015 Enterprise w/Update 3
  • This extension: 1.4.3

Description

Creating a Unit test and placing in a NUnit based assembly generates a VS Test Tools Unit Test.

Steps to recreate

Create a Unit Test and select an assembly for output that contains NUnit tests

Expected behavior

Ideally it would recognize that NUnit is being used in the destination assembly and create a unit test that leverages NUnit attributes and using clauses

Getting error while generating test cases

Installed product versions

  • Visual Studio: [example 2017 Professional]

Current behavior

When I am creating test cases by right click on the file and click on"Create Unit Test For Boilerplate" the test file is generated but it is asking to add Visual studio or any of the desired test framework reference. Please find attachment herewith for your reference.

Expected behavior

It should generate the test case without asking to add the reference of any of the framework
BoilerPlate

Not implemented Exception

Installed product versions

  • Visual Studio: VS2017 Community 15.9.0
  • This extension: 1.9.10

Description

Not implemented Exception, NUnit & Moq options selected

Steps to recreate

  1. Right click on .cs file
  2. Click "Create Unit Test Boilerplate..."
  3. Error Exception HRESULT 0x80004001 (E_NOTIMPL)
    2018-11-15_10-30-10

Current behavior

Unable to create a boilerplate test file

Expected behavior

Able to create a boilerplate test file.

Exception when clicking on "Create Unit test boilerpalte..."

Installed product versions

  • Visual Studio: 2015 Community
  • This extension: 1.7.0

Description

This extension was working for a time. Now, every time i try to create a new xx i get the exception:

"The type initializer for UnitTestBoilerplate.StaticBoilerplateSettings threw an exception."

Steps to recreate

  1. Right click on any class
  2. Select "Create Unit test boilerpalte..."

Current behavior

No unit test file is created due to the exception.

Expected behavior

A new unit test file should be created.

Extension v1.9.6 not working in VS 2015 Community

Installed product versions

  • Visual Studio: 2015 Community
  • This extension: 1.9.6

Description

Extension not working any more. Context menu does not show dialog. Options page cannot be displayed.

From the ActivityLog i get the error:

LegacySitePackage failed for package [CreateUnitTestBoilerplateCommandPackage]Source: 'UnitTestBoilerplate' Description: Could not load file or assembly 'Microsoft.VisualStudio.ComponentModelHost, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

I figured out that the missing assembly is related to VS 2017 SDK. So seems that the extension for VS 2015 is referencing an assembly from VS 2017. In VS 2017 the extension is working properly.

Add boilerplate for internals

Installed product versions

  • Visual Studio: 15.6.3
  • This extension: 1.9.10

Description

Generation of test methods for internal members.
Sugar: Automatically add [assembly: InternalsVisibleTo("%TargetNamespace%.Tests")]

Default target framework and mock framework

Hi

Just want to start by saying that this extension is the best thing since sliced cheeeeszzee.

Installed product versions

  • Visual Studio: 2017
  • This extension: newest

Description

Is it possible that the tools->options can get a "IsDefault" for the test framework and the mock framework. So i don't need to change to NUnit and NSubstritute, which is my companies weapon of choice...

Regards, Rik

"Could not find class declaration" exception thrown when generating boiletplate

Installed product versions

  • Visual Studio: 2017 Community
  • This extension: 1.9.20

Description

Exception is thrown when creating unit test boilerplate.

Current behavior

Creating a unit test boilerplate throws exception that says it could not find class declaration.

image

Expected behavior

It should create a unit test boilerplate.

Notes

It might help investigating that my project name starts with digits:
image
But namespaces start with ordinary letters.

Support for FluentValidation

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/

NullReferenceException when attempting to generate test class

Installed product versions

  • Visual Studio: 2017 Enterprise 15.9.0
  • This extension: 1.9.10

Description

NullReferenceException when attempting to generate test class.
image

Project implements Caliburn.Micro as the IoC framework. Test project uses Moq and xUnit.
Class has a single constructor with parameters; two are dynamic, others are instantiated objects and interfaces. Project is .NET Framework 4.6.2

Steps to recreate

  1. Select class to generate test class from
  2. Ensure proper testing frameworks and project are selected.
  3. Click Create Unit Test Class button
  4. Exception dialog should now be displayed.

Current behavior

Exception dialog displays and no test class is generated.

Expected behavior

No exception dialog displayed and test class is generated.

Method not found

Installed product versions

  • Visual Studio: 2017
  • This extension: 1.10.5

Description

Crash after click button "Create Unit Test Class"

Steps to recreate

  1. Empty Soultion with two Projects
  • Console Project
  • MsTest Project

Current behavior

Crash
2019-07-11 07_00_15-Window

Support Windows Runtime and mock libs that work on it i.e. SimpleStubs

Description

Windows Runtime libraries (UWP) and components are not supported by majority of testing tools properly. It would be great to have it supported by this generator. Unfortunately the only mock library which supports WinRT is SimpleStubs library by Microsoft (if I am wrong pls correct me).

Jacek

FR: Add NSubstitute mocking support

Installed product versions

  • Visual Studio: [example 2015 Professional]
  • This extension: [example 1.1.21]

Description

We're not using Moq so I end up removing a fair chunk of the generated code. I'm a huge fan of the template idea seen in Issue 6, but aside from that, having native NSubstitute support as an option would be great. Perhaps in some kind of options/plugin configuration menu where you can specify how you want the template set up, which mocking framework to use, etc.

Feature request - Create stubs for methods

I'd love to see the boilerplate create a test stub for each public method (and property?) in the class with a simple Assert.Fail() rather than the current "TestMethod1"

Issue: Namespace generated incorrect in solution with multiple projects

Installed product versions

  • Visual Studio: [example 2015 Professional]
  • This extension: [example 1.1.21]

Description

I have a solution with 5 different projects, and when I generate the boilerplate file and specify the test project, the namespace doesn't contain the test project name, starting with a "." instead, which results in compiler errors.

Could this be related to my project being ASP.NET Core? Has this library been tested there?

Steps to recreate

  1. Create ASP.NET Core solution with a test project aside from the src projects.
  2. Generate a test file using the tool for a non-test-project class.
  3. Specify the Test project.

Current behavior

namespace is missing the test project name, resulting in a compiler error as it starts with "."

Expected behavior

namespace contains the project name followed by the correct path

Ability to add custom Mock and Test framework templates

Installed product versions

  • Visual Studio: Proffesional 2017 Preview v 15.8.0 Preview 4
  • This extension: V 1.9.10

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

Allow lower-case field names for generated mocks

According to standard naming rules, the mock field names should start with lowercase. For example, if a dependency has the name IFoobar, the test class field name for that dependency will currently be Foobar, while it should be foobar.

I therefore suggest you facilitate this somehow, e.g. by adding a token $InterfaceMockNameLower$ or simply changing the casing rules for these fields.

Include option for No Mock Library

Installed product versions

  • Visual Studio: Proffesional 2017 Preview v 15.8.0 Preview 4
  • This extension: V 1.9.10

Description

Please add an option for using no Mock library. In many cases, we don't want a Mock layer in our testing. I do use mocks and appreciate them very much but mocks are not a one size fits all answer.

In many cases I want a simple test class constructed. A method for creating the object is great and a few support functions but otherwise just a basic class object would be wonderful.

Expected behavior

Right click on class and select "Create Unit Test Boilerplate..."
Choose the appropriate test framework.
In the Mock Framework drop-down there would be a selection of "None"

Create Unit Test would then create a test class using the appropriate template using No Mock library.

Customize TestMethods template

Installed product versions

  • Visual Studio: 2017 15.9.2 Professional
  • This extension: 1.9.12

Description

I'm using xUnit and NSubstitute to create unit tests. Is possible to define my own $TestMethods$ variable?

Current behavior

Current TestMethods will generate the code below. It always compiles failed on TODO and Assert.Fail(), it kind of annoying for me

        [Fact]
        public void Post_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var unitUnderTest = CreateValuesController();
            string value = TODO;

            // Act
            unitUnderTest.Post(
                value);

            // Assert
            Assert.Fail();
        }

Expected behavior

I will expect to generate the code below. No compile error.

        [Fact]
        public void Post_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            var unitUnderTest = CreateValuesController();
            string value = "";

            // Act
            unitUnderTest.Post(
                value);

            // Assert
            Assert.True(false, "Not Implement");
        }
```

Miles regards.

Support csproj-based projects

When the test project is csproj-based, the boilerplate generator does not seem to recognize the testing/mocking frameworks.

Workaround: Use the "Unknown" mock framework template. It's not perfect (the using statements are wrong), but gets you 90% of the way while waiting for a fix.

TODO - replace with a variable

Installed product versions

  • Visual Studio: [example 2015 Professional]
  • This extension: [example 1.8.0]

Description

COnstructor - parameter "TODO" instead of integer

Steps to recreate

Class with constructor with integer
Ctor(Interface service, int ala)

Current behavior

putting "TODO" instead of a typed variable, like integer

Expected behavior

variable of correct type

Failing to generate unit test for structs

Installed product versions

  • Visual Studio: 2019 Community Version 16.5.0 Preview 2.0
  • This extension: 2.2.0

Description

Throws exception "InvalidOperationException: Could not find class declaration." when trying to generate unit test for a struct. I assume this is a current limitation. In this case consider this to be a feature request.

Steps to recreate

  1. Create as *.cs file containing only a struct.
  2. Right click in solution explorer and select "Create Unit Test Boilerplate..."
  3. Select Test Framework: VisualStudio
  4. Select Mock Framework: NSubstitute
  5. Click button "Create Unit Test Class"

Current behavior

Throws exception "InvalidOperationException: Could not find class declaration."

Expected behavior

Should generate unit test.

Cannot add to existing test

Installed product versions

  • Visual Studio: 2017
  • This extension: latest

Description

i do not seam to be able to add to an existing test. I.e. a new test method. from the termplate.
Kan the extension not adding tests to existing unit test classes though automation?

Steps to recreate

  1. Have a test class created.
  2. Then try to add/update to existing ctest class

Expected behavior

I would like to be able to add a test on top of existing tests with new methods in a class

Crashes when testfile already exists

Installed product versions

  • Visual Studio: VS 2019 Professional
  • This extension: 2.3.0

Description

Crashes with 'File already exists' when test file already exists

Steps to recreate

  1. Have a Test project already in place with a Class File named as being generated from tool
  2. right click on class file for which test should be generated
  3. confirm "Generate Unit Test"
  4. Crash

Current behavior

Obviously doesn't check whether the file exists
See screenshot:
image

Expected behavior

Should check whether file exists and prompt to confirm overwrite

Creating boilerplate unit testing project template

Hi there,

Ive used the generator to generate unit testing on a previous project but forgot how to use this to setup a blank unit testing project template?

Am I imagining things or was this possible to create a blank unit testing project template because as I think I remember correctly I used this to setup a template project using NUnit and NSubstitute but cannot recall the steps.

Im not referring to simply creating the boiler plate code for a class but rather an actual project template ready to begin adding unit test files. Can you confirm if this is possible otherwise I must have setup a project manually myself.

Exception HRESULT 0x80004001 (E_NOTIMPL)

Installed product versions

  • Visual Studio: 2017 Professional (15.2)
  • This extension: 1.5.10

Description

The generator was working fine for me, then suddenly (in the same session, without restarting VS), when right-clicking a file in the solution explorer and selecting "Create Unit Test Boilerplate", I got this error:

error

This now seems to happen for any file I try it with. I have tried uninstalling and reinstalling the plugin, as well as resetting the template to default settings. I have no idea what caused this in the first place, nor how to debug this to provide more information. Please let me know how I can assist.

Edit Template for Test method

Installed product versions

  • Visual Studio: 2019 Professional
  • This extension: 1.9.20

Description

It would be great to have the option to pre-format the test method template the Options menu the same as we currently can with the class declaration.

Expected behavior

Menu > Tools > Options....
Select "Unit Test Boilerplate Generator"
Have Option for "Test Method Contents"
This will provide a similar set of options to the "Test File Contents" options to allow the test method template to be edited

NotSupportedException: Parameter type not supported when creating test file.

Installed product versions

  • Visual Studio: 2017
  • This extension: 1.9.0
    Also using: Resharper ultimate
    Also, this is a C#, C++/CLI solution.

Description

Exception thrown when trying to create a new unit test file. First time using this extension.

Steps to recreate

  1. Right click the file I want to create unit tests for
  2. Click on the boilerplate icon
  3. Select Test Project, Nunit and Moq

Current behavior

Throws exception:

System.NotSupportedException: Parameter type not supported

at UnitTestBoilerplate.Services.TestGenerationService.GetSimpleTypeName(TypeSyntax argumentType) in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 372

at UnitTestBoilerplate.Services.TestGenerationService.GetArgumentDescriptors(List`1 argumentList, SemanticModel semanticModel, MockFramework mockFramework) in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 316

at UnitTestBoilerplate.Services.TestGenerationService.d__9.MoveNext() in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 231

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.Services.TestGenerationService.d__17.MoveNext() in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 388

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.Services.TestGenerationService.d__6.MoveNext() in C:\projects\unittestboilerplategenerator\src\Services\TestGenerationService.cs:line 57

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.d__54.MoveNext() in C:\projects\unittestboilerplategenerator\src\ViewModel\CreateUnitTestBoilerplateViewModel.cs:line 181

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at UnitTestBoilerplate.ViewModel.CreateUnitTestBoilerplateViewModel.<<get_CreateUnitTestCommand>b__53_0>d.MoveNext() in C:\projects\unittestboilerplategenerator\src\ViewModel\CreateUnitTestBoilerplateViewModel.cs:line 166

Expected behavior

It should create the test file, I guess? :)

Unit Test Creation with SQL Server Database Project

Installed product versions

  • Visual Studio: [example 2017 Enterprise 15.9.9]
  • This extension: [example 1.9.17]

Description

I do have in my solution one project of type "sql server database project"
On create a new test with "Create Unit Test Boilerplate...." VS popup a error
"Could not find file 'c:\windows\system32{$projectName}.sqlproj.

When i unload this mentioned project, create unit test boilerplate works

Nunit support

Hi

Great extension, really useful. What would be involved in adding support for nunit? I often use the "Create unit tests" feature in Studio with the nunit adapter installed but the handling of Moq and DI in this extension is better so would happily swap if nunit was supported. I suspect this would increase potential userbase for this extension considerably.

Thanks

Using "Import Project" in the test csproj (embedding the test framework in props) stops auto detection

Installed product versions

  • Visual Studio: VS 2019 V16.6.0
  • This extension: 2.4.0

Description

Looks like after VS16.6.0 update that the boilerplate:

  • Using "Import Project" in the test csproj (embedding the test framework in props) stops auto-detection

image

Steps to recreate

  1. Create a central project props file
  2. import the props file to the test csproj
  3. Try to generate a test using boiler plate

image

Current behavior

It cannot "collect" the test and mock framework from the project import

Expected behavior

The auto discover still works.

OR, is there an attribute or something we can add to the CSPROJ so it discovers the framework + sub?

Thanks for WONDERFUL extension

Generating unit test on wrong unit test project

Installed product versions

  • Visual Studio: Enterprise 2019
  • This extension: 16.4.3

Description

When creating a unit test using the UnitTestBoilerplateGenerator, it generates the unit test for the first relative path in a specified unit test project inside the solution. Not always it will be right.

For example, I have the following projects in my solution:

  • Something.Api
  • Something.Api.Client
  • Something.Api.Client.UnitTests
  • Something.Api.UnitTests

When generating a unit test for Something.Api project, it will generate in Something.Api.Client.UnitTests.

Steps to recreate

  1. Create the example projects: Something.Api, Something.Api.Client, Something.Api.Client.UnitTests, Something.Api.UnitTests
  2. Right-click an item in Something.Api and choose "Create Unit Test Boilerplate"

Current behavior

Right-click an item in Something.Api and choose "Create Unit Test Boilerplate" . It generates a unit in Something.Api.Client.UnitTests.

Expected behavior

Right-click an item in Something.Api and choose "Create Unit Test Boilerplate" . It generates a unit in Something.Api.UnitTests.

Methods template

Installed product versions

  • Visual Studio: 2017 Professional
  • This extension: 1.9.10

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.

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.