简体   繁体   English

NUnit并行运行测试

[英]NUnit Running Tests in Parallel

I have a test which loops over a List and runs a test! 我有一个循环遍历列表并运行测试的测试! I would like to however make this run in parallel. 但是,我想使它并行运行。 Is there a way that I could do this? 有办法可以做到吗? Can I create my List to be parallelizable? 我可以创建可并行化的列表吗?

I guess I figured that out! 我想我知道了! All I had to do is to call AsParallel on my List! 我要做的就是在清单上调用AsParallel!

Assume that I have a List of Id's which is of type String and I want to run a test for each of the entry, I can do the following inside my test method! 假设我有一个Id的列表,其类型为String,并且我想为每个条目运行一个测试,则可以在我的测试方法中执行以下操作!

myList.AsParallel.SelectMany(entry =>
{
   // execute the test for each of the entry
   // return entry;
});

What I noticed is that the time taken to run all the tests for each element in my List reduced significantly by running them in parallel! 我注意到的是,通过并行运行列表中的每个元素来运行所有测试所需的时间大大减少了!

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

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