How do you test private methods with NUnit?

后端 未结 13 2431
春和景丽
春和景丽 2020-12-02 16:00

I am wondering how to use NUnit correctly. First, I created a separate test project that uses my main project as reference. But in that case, I am not able to test private m

13条回答
  •  臣服心动
    2020-12-02 17:01

    You can make your methods protected internal, and then using assembly: InternalsVisibleTo("NAMESPACE") to your testing namespace.

    Hence, NO! You cannot access private methods, but this is a work-around.

提交回复
热议问题