简体   繁体   English

这在NUnit中是否可行

[英]Is this possible in NUnit

What i want is a project with several files in it. 我想要的是一个包含多个文件的项目。 Each file has a set of tests. 每个文件都有一组测试。 Then I want to be able to run each of those tests. 然后我希望能够运行每个测试。

So right now I have a project but I only have one file: Project.cs. 所以现在我有一个项目,但我只有一个文件:Project.cs。 When i run the test through the console/GUI All them tests from Project.cs are run (or a subset if i use the /fixture command). 当我通过控制台/ GUI运行测试时,运行Project.cs中的所有测试(如果我使用/ fixture命令,则运行子集)。 What I would like (or would like to know if its possible) would be the following. 我希望(或者想知道它是否可能)将是以下内容。

Have a Project called Tests. 有一个叫做测试的项目。 In that I have several files FileTests.cs, ControlTests.cs, MiscTests.cs, etc each of these have various tests. 在那里我有几个文件FileTests.cs,ControlTests.cs,MiscTests.cs等,每个文件都有各种测试。 Then there is also a Program.cs. 然后还有一个Program.cs。 I would be able to run the Tests project and choose which of the FileTests, ControlTests, etc I run. 我可以运行Tests项目并选择我运行的FileTests,ControlTests等。

Is that possible? 那可能吗?

Cheers 干杯

Sounds like you are looking for NUnit test categories . 听起来你正在寻找NUnit测试类别 You can attribute you test with the correct category and then run just tests belonging to that category. 您可以使用正确的类别对测试进行测试,然后仅运行属于该类别的测试。 This gives you much more flexibility than having to define them physically as files or assemblies. 这比在物理上将它们定义为文件或程序集更具灵活性。

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

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