RandomEngy / 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, XUnit and many mock frameworks.
https://marketplace.visualstudio.com/items?itemName=RandomEngy.UnitTestBoilerplateGenerator
MIT License
64 stars 17 forks source link

Feature Request: add InternalsVisibleTo when creating tests for internal classes #32

Open Hefaistos68 opened 1 year ago

Hefaistos68 commented 1 year ago

Description

When adding a unit test for a class that is protected, its required to add the "InternalsVisibleTo" to the origin (either as attribute in the file or in the project file (https://www.meziantou.net/declaring-internalsvisibleto-in-the-csproj.htm)

Would be nice to have it detect that the origin class is protected and InternalsVisibleTo is required and then adds it according to the configured prefered method.

RandomEngy commented 1 year ago

It looks like from that article you can set it up for the whole project to expose its internals to test assemblies. It doesn't seem to be in the scope of the project; which is creating boilerplate test code targeting a given file. It looks like there are different strategies to expose test internals as well. I could see this being a separate extension if you'd like to try to automate it.

For a bit more context, UTBG currently does not edit .csproj properties at all, except for just adding the file to the test .csproj.