NUnit 基类

发布于 2024-12-04 17:07:33 字数 160 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天涯沦落人 2024-12-11 17:07:33

如果您不想将集成测试和单元测试拆分到单独的项目中,您还可以将测试分组到类别中

[Test, Category("Integration")]

大多数测试运行程序允许您过滤要运行的类别,这将在您需要时为您提供更细粒度的控制(例如“快速”) ,“慢”和“真的很慢”类别)

If you don't want to split out integration and unit tests into separate projects you can also group tests into categories

[Test, Category("Integration")]

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)

苍景流年 2024-12-11 17:07:33

推荐的方法是将可以独立于集成测试运行的单元测试分离到不同的项目中,然后您可以在运行测试时选择要执行的项目。这将使您更频繁地、每天多次甚至每小时运行更快的测试变得更容易(并且希望不必担心配置之类的事情),同时让您运行较慢的集成测试按不同的时间表运行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文