devxlogo

Unit Test Non-Public Methods in C# Unit Tests

Unit Test Non-Public Methods in C# Unit Tests

To expose non-public methods to the test project, you need to mark the assembly with an attribute called InternalsVisibleTo in the asemblyinfo.cs file??

For example:

[assembly: InternalsVisibleTo("testProjectName")]

You need to mark the methods as Internal, and they will available for you to test in the test project.

devx-admin

Share the Post: