简体   繁体   中英

NUnit/TestDriven (product, not methodology), is it possible to ignore a category of tests by default?

We're in the process of defining automated performance tests using NUnit. However, since many of these will run for a bit of time, to cater for inaccuracies in timing and load on the system, we don't want the developers to have to run these under normal development.

Is there any way we can instruct the TestDriven Visual Studio addin to ignore a set of unit tests, so that if the programmer just right-clicks on the unit-test project and selects "Run Tests", those tests are not executed?

It seems the only way to make tests be ignored by default is through the [Explicit] attribute, but that means I incur a maintenance overhead on our test server, since there doesn't seem to be a way to execute all the explicit tests in one fell swoop without naming them all.

Or should I just separate out all the performance tests to its separate project and just instruct the programmers to leave it alone (at least until they need to update the tests) ?

I would create a separate testing assembly. Then you can have your normal unit tests in one assembly and performance tests in a second assembly.

That way, at development time the developers never run the perf tests. At build time you could execute both test assemblies to make sure that both Unit & Perf tests are run.

I would do this not just so that some tests wouldn't have to get run, but it offers a better distinction of what's in that assembly. This new assembly isn't a set of "Unit" tests. And as you bring new devs on, there wouldn't be any confusion to how you guys write tests. You wouldn't want a new guy looking at a perf test and thinking that's how to write unit tests.

As for the concrete question, ask TestDriven to avoid running your performance tests, check the settings dialog under "Tools->Options":

TestDriven.NET选项

What about the [ignore] attribute? Maybe I am misunderstanding, but it sounds to me like this will do the trick for you??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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