Unit testing and checking private variable value

后端 未结 6 1706
难免孤独
难免孤独 2020-11-27 04:27

I am writing unit tests with C#, NUnit and Rhino Mocks. Here are the relevant parts of a class I am testing:

public class ClassToBeTested
{
    private IList         


        
6条回答
  •  时光说笑
    2020-11-27 04:54

    The number of tests you need is dependent on the complexity of the code - how many decision points are there, roughly. Different algorithms can achieve the same result with different complexity in their implementation. How do you write a test that is independent of the implementation and still be sure you have adequate coverage of your decision points?

    Now, if you are designing larger tests, at say the integration level, then, no, you would not want to write to implementation or test private methods, but the question was directed to the small, unit test scope.

提交回复
热议问题