限制 NUnit 项目中的并行线程数

Limit number of parallel threads in NUnit Project

我正在 运行NUnit 项目中并行进行 selenium 测试,我想限制一次 运行 的测试数量

我找到的解决方案说要指定:[assembly: LevelOfParallelism(N)] 到 AssemblyInfo.cs,但我的 NUnit 项目没有 AssemblyInfo.cs

我想限制在 NUnit 项目中并行执行的 selenium 测试的数量运行

documentation说的是might,不是必须在AssemblyInfo.cs:

The following code, which might be placed in AssemblyInfo.cs


您可以将 [assembly:LevelOfParallelism(3)] 添加到您的测试夹具 .cs 文件中。查看更多关于程序集属性 here.

using System;

[assembly: LevelOfParallelism(3)]

namespace YourNamespace
{
    [TestFixture]
    public class YourTextFixture
    {
    }
}

注意:您始终可以将 AssemblyInfo.cs 添加到您的 NUnit 项目中。只需在顶层添加一个名为 AssemblyInfo.cs 的文件,您就可以在其中添加任何程序集标志。