简体   繁体   English

使测试在 Nunit 测试项目中最后运行

[英]make Test run last in a Nunit test project

from what i could find till now, i am not sure it is possible, but maybe there is something that i am missing.从我能找到的到现在,我不确定这是否可能,但也许我缺少一些东西。

like in any test project we have lots of tests classes ( in our case these are E2E tests that runs on an live system)就像在任何测试项目中一样,我们有很多测试类(在我们的例子中,这些是在实时系统上运行的 E2E 测试)

when in some tests we need to run a script as a prerequisite that triggers an iis reset command.在某些测试中,我们需要运行一个脚本作为触发 iis 重置命令的先决条件。

which affect other tests..这会影响其他测试..

so what we want achieve is running these tests ( tests that triggers iisrest one by one ) after all other tests where executed.所以我们想要实现的是在执行所有其他测试之后运行这些测试(一个一个触发 iisrest 的测试)。

thanks谢谢

You can use the OrderAttribute from NUnit on your tests or you could potentially split the tests into separate TestFixtures so that they do not interfere with each other.您可以在测试中使用 NUnit 中的OrderAttribute ,或者您可以将测试拆分为单独的 TestFixture,这样它们就不会相互干扰。

I'm sure others will suggest that all tests should be able to run in any order without affecting any others but my experience is that ordering is sometimes much easier than trying to make each test run completely independently.我相信其他人会建议所有测试都应该能够以任何顺序运行而不会影响任何其他测试,但我的经验是,排序有时比尝试让每个测试完全独立运行要容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM