C # - testing the VS 2010 module for private methods

VS 2010 allows private module testing. Is that a good idea? I have always heard that unit test scripts were for public methods only. Should I worry about private methods and properties?

Thanks Leo

+5
source share
4 answers

In his infinite wisdom, John Skeet once wrote (in C # in depth) "I am happy to test everything I can in the simplest way"

IMHO, if you think a private method deserves unit testing, check it out.

+5
source

Two reasons not to test private methods:

1) . - , , , , .

2) . , , . , .

+1

/, / ( , ). / - /.

/, . ( , ), , .

0
source

As already mentioned, test it if you feel the need and you can, but keep in mind that the unit test of a private method is likely to be violated if someone modifies it, which can be a great pain in the ass in a large project with a large number of unit tests, my advice would be to check only those methods whose functionality is very clear and unlikely to be changed.

0
source

All Articles