Alex Rivera | Logout

Is it considered bad practice to use InternalsVisibleTo for Unit Test Code?

Asked 2011-09-28T08:59:05.350
41

Sample code in framework's AssemblyInfo.cs:

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo
                          ("Test.Company.Department.Core")]

Is this a bad practice?

Edit
Report

1 Answer

4

InternalsVisibleTo could be useful if you need to test sub parts of your API which you don't want to expose.

However, testing through the public API is preferable since it makes refactoring internal APIs easier. Use InternalsVisibleTo with care and only when appropriate, e.g. the size of the API is significant.

answered 2011-09-28T09:05:35.477

Your Answer