mattwhitfield / Unitverse

A unit test generation extension for Visual Studio that aims to always produce code that compiles - covering the basic cases automatically and preparing as much as it can for the complex cases.
MIT License
89 stars 20 forks source link

Support for deriving generated unit test classes from a base class #163

Closed AdaTheDev closed 1 year ago

AdaTheDev commented 1 year ago

It would be great to have an option under "Generation Options" to specify a base class from which generated unit test classes should derive from. This would help scenarios where currently, you have to manually inherit from a base class post-generation - not a huge inconvenience, but 1 less thing to cover when onboarding a team to the tool (of awesomeness).

mattwhitfield commented 1 year ago

This is resolved in 0.160 - you can set 'Test type base class' and 'Test type base class namespace' in the UI or set TestTypeBaseClass=MyClassName and TestTypeBaseClassNamespace=My.Awesome.Namespace in a .unitTestGeneratorConfig file.

You can operate it one of two ways - you can either specify a fully qualified type name in TestTypeBaseClass and leave TestTypeBaseClassNamespace blank, or you can specify a type name only in TestTypeBaseClass and put the namespace in TestTypeBaseClassNamespace, in which case it will emit a using for the namespace.

They are just strings - there isn't anything that does type lookups or validation on what's entered - so just be aware that it's possible to put rubbish in there and the tool really won't be any the wiser. 👍

AdaTheDev commented 1 year ago

This is awesome. Thanks. Already being put to good use 👍