Unit Test Stub Generation

Answered

Visual Studio can generate Unit Test stubs for a given class for MSTest / NUnit / XUnit. 

It would be nice to have a code generation option that, when triggered on a class, creates a test file in a selected test project, and iterates through the class's public members creating test method stubs. 

Even nicer still would be if you could do it for all the public classes in a directory. 

10
5 comments

Hi, please feel free to watch and upvote a related youtrack issue.

0

Not the solution but a workaround to make life a bit easier. In my test class I temporarily add the interface to test and then select implement missing members. Remove the interface and at least the stubs are there although the [Test] attibute needs to be added.

If you don't have an interface, you can create a field temporarily and take Code / Genrate / Delegating members.

0

Could you guys look at this for inspiration:

https://marketplace.visualstudio.com/items?itemName=RandomEngy.UnitTestBoilerplateGenerator

 

It saves a lot of time and standardises test look and feel between developers. It is n't perfect, bu i am sure you guys could make something better.

I write a lot of tests, and until something like this extension is created, Rider will also be more difficult to use :-/

 

 

0

Hi Julia Vaseva or support

the youtrack issue created/linked is for intelliJ not Rider --> can you create a rider equivalent?

Many thanks,

Simon

0

Hi Simon! 

The mentioned issue RSRP-34142 also relates to Rider as we reuse parts of our products. Please, feel free to upvote it.

0

Please sign in to leave a comment.