简体   繁体   English

使用NUnit工具运行特定的TestFixture类

[英]Running a particular TestFixture class using NUnit tool

I have implemented unit tests for my MVC Application using the NUnit Framework. 我已经使用NUnit Framework为我的MVC应用程序实现了单元测试。 The Unit testing project contains multiple [TestFixture] classes that need to be tested. 单元测试项目包含多个需要测试的[TestFixture]类。 I'm using a TestFixture for each Module in my MVC project, but all of the modules are inside in single Namespace. 我在MVC项目中为每个模块使用TestFixture ,但是所有模块都位于单个命名空间中。

I would like to be able to test a single Module through its [TestFixture] using the Unit Tool in FinalBuilder (automation) or Manually, instead of testing the whole unit test project. 我希望能够使用FinalBuilder(自动化)或手动中的单元工具通过其[TestFixture]测试单个模块,而不是测试整个单元测试项目。

My total test case count is around 2000, made up of 20 modules each with about 100 test cases. 我的测试用例总数约为2000,由20个模块组成,每个模块包含约100个测试用例。 Any changes made to one of modules or it's TestFixture will mean that only that modules tests need to be run. 任何改变的一个模块制造或它TestFixture将意味着只有模块的测试需要运行。 This will minimise the amount of time that needs to be taken to wait for unrelated tests to complete. 这将最小化等待无关测试完成所需的时间。

As far as manual testing goes, in the Nunit gui, you can simply select a test fixture and run it to. 就手动测试而言,在Nunit gui中,您只需选择一个测试夹具并将其运行即可。 I haven't used finalbuilder, but assuming it's similar to the nunit-console application, you have a couple of options. 我没有使用finalbuilder,但是假设它与nunit-console应用程序相似,则有两个选择。

You can pass arguments to specify particular test cases, for example: 您可以传递参数以指定特定的测试用例,例如:

nunit-console some.dll /run=SomeTestFixture

Or, you can mark up your test fixtures with categories and then tell the test runner to only include tests in those categories, so in your code: 或者,您可以用类别标记测试设备,然后告诉测试运行者仅将测试包含在这些类别中,因此在代码中:

[TestFixture]
[Category("SomeTestCategory")]
public class SomeTestClass {

Then in your nunit call: 然后在您的nunit调用中:

nunit-console some.dll /include=SomeTestCategory

That said, assuming that your tests are actually unit tests, 2000 doesn't seem like that many and they shouldn't really be taking all that long to run... 就是说,假设您的测试实际上是单元测试,那么2000似乎并没有那么多,并且它们实际上不需要花那么长时间来运行...

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

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