问题描述
我想知道将Nunit代码放在必须相同的类中是个好主意吗
使用单元测试进行测试.那是同一类中的业务逻辑和测试代码.
可以使用部分类功能将测试代码放入另一个文件中.
可能是一些嵌套的类来放置实际的测试代码.并且可以有条件地编译此代码.我想这样做是因为我相信这种方法将使使用Nunit轻松测试私有方法成为可能.首先我想知道这可能吗?如果是的话,这种方法可能会给那些具有连续集成之类的大型项目带来特别的问题.
如果是愚蠢的问题,请告诉我.
I want to know is it good idea to put Nunit code in same class that has to be
tested using unit tests. That is business logic & test code in same class.
Partial class feature can be used to put the test code in to another file.
May be some nested class to put actual testing code. And this code can be compiled conditionally. I want to do this because I believe this approach will make it possible to easily test private methods with Nunit. First I want to know is it possible? If yes what can be the problelms with this approach specially for large projects having continueous integration and stuff like that.
If its stupid question please tell me.
推荐答案
这篇关于使用条件编译进行单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!