NUnit 基类
我正在使用 NUnit 进行数据库测试。因为它很耗时,所以我不想每次都跑步。
因此,我尝试创建基类,并从它派生所有其他数据库测试类,因为我想如果我用 [Ignore] 属性装饰基类,那么其余的派生类将被忽略,但这并没有发生。
我需要知道有什么方法可以以最小的努力忽略一组类?
I am approaching database testing with NUnit. As its time consuming so I don't want to run everytime.
So, I tried creating the base class and every other database testing classes derive from it as I thought if I will decorate the base class with [Ignore] attribute then rest of the derived classes will get ignored, but thats not happening.
I need to know is there any way to Ignore set of the classes with minimal effort?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想将集成测试和单元测试拆分到单独的项目中,您还可以将测试分组到类别中
大多数测试运行程序允许您过滤要运行的类别,这将在您需要时为您提供更细粒度的控制(例如“快速”) ,“慢”和“真的很慢”类别)
If you don't want to split out integration and unit tests into separate projects you can also group tests into categories
Most test runners allow you to filter which categories to run which would give you finer grained control if you need it (e.g. 'quick', 'slow' and 'reaaallyy slow' categories)
推荐的方法是将可以独立于集成测试运行的单元测试分离到不同的项目中,然后您可以在运行测试时选择要执行的项目。这将使您更频繁地、每天多次甚至每小时运行更快的测试变得更容易(并且希望不必担心配置之类的事情),同时让您运行较慢的集成测试按不同的时间表运行。
A recommended approach is seperating your unit tests that can run in isolation from your integration tests into different projects, then you can choose which project to execute when you run your tests. This will make it easier to run your faster running tests more often, multiple times daily or even hourly (and hopefully without ever having to worry about such things as configuration), while letting your slower running integration tests run on a different schedule.