【发布时间】:2022-02-04 03:31:45
【问题描述】:
我对 Visual Studio 2019 中的 Selenium 测试的 NUnit 测试设置(.NET Core 3.1 和 NUnit 3)有疑问。
在 AssemblyInfo.cs 中,我添加了 2 行。
[程序集:可并行化(ParallelScope.Children)]
[程序集:LevelOfParallelism(4)]
代码很简单。在 SetUp() 中初始化驱动程序。但是,当使用测试资源管理器运行 2 个测试时,会打开 2 个 chrome 窗口。但它们没有并行运行(仍然无法使用 Setup、OneTimeSetup 属性)
如果我直接在TestMethod中初始化驱动就可以了,但是就是骗码。
这是否意味着同一个 TestFixture 中的 NUnit Selenium 测试不能并行运行?
谢谢, 雷
[TestFixture]
public class Account : BaseTest
{
[SetUp]
public void Setup()
{
_driver = new ChromeDriver();
_driver.Manage().Window.Maximize();
}
[Test]
[Category("UAT")]
[Order(1)]
public void Test1()
{
_driver.Navigate().GoToUrl("https://www.msn.com");
Assert.AreEqual("https://www.msn.com/", _driver.Url);
}
[Test]
[Category("UAT")]
[Order(0)]
public void Test2()
{
_driver.Navigate().GoToUrl("https://www.google.com");
Assert.AreEqual("https://www.google.com/", _driver.Url);
}
【问题讨论】: