Making code internal but available for unit testing from other projects

前端 未结 4 1654
走了就别回头了
走了就别回头了 2020-12-04 10:26

We put all of our unit tests in their own projects. We find that we have to make certain classes public instead of internal just for the unit tests. Is there anyway to avo

4条回答
  •  一整个雨季
    2020-12-04 11:16

    Classes can be both public AND sealed.

    But, don't do that.

    You can create a tool to reflect over internal classes, and emit a new class that accesses everything via reflection. MSTest does that.

    Edit: I mean, if you don't want to include -any- testing stuff in your original assembly; this also works if the members are private.

提交回复
热议问题