How to unit test private methods in BDD / TDD?

前端 未结 12 1010
攒了一身酷
攒了一身酷 2020-12-15 22:03

I am trying to program according to Behavior Driven Development, which states that no line of code should be written without writing failing unit test first.

My ques

12条回答
  •  情书的邮戳
    2020-12-15 22:25

    Mbunit Reflector helps you with this.

    Reflector objectReflection = new Reflector(new ObjectWithprivateMethods());
    objectReflection.InvokeMethod(AccessModifier.NonPublic,,"Add",1,6));
    

    A blog post about it.

提交回复
热议问题