Why is Private Accessor Deprecated?

This used to be the number one reason for us to choose MSTest from others so that we can access and test private methods. Now that Private Access Devices has been deprecated in Visual Studio 2012 . Does anyone know why Microsoft makes this decision? Is it because it is not recommended to check private methods?

Also, if I still need to unit test my private methods, how can I do this in VS 2012 and later?

+4
c # mstest
source share
1 answer

According to an article by the VS Team Generating Private Accessories ... this feature was deprecated in 2010 for the following reasons:

  • Lack of resources and time . The focus of this issue was on improving the experience for hand-held testers, so the priority for generating and publishing code was reduced. There were other issues with the publicize functions that we use that have not been fixed.

  • New features of language commands . Since language teams made changes to their project types and languages, we were not able to respond to the changes made by them and were unable to work with the new features that they introduced.

(More detailed historical notes can be found using the following search: mstest, why a personal accessory robbed the site: blogs.msdn.com ).

For your second part of the question - usually you do not need to perform individual tests. If you really need to expose such testing methods, consider whether internal labeling and using a friend ( InternalsVisibleToAttribute ) will work for you.

+5
source share