【发布时间】:2020-01-24 13:46:51
【问题描述】:
我使用 NUnit 创建了一个 selenium 测试框架,有一个测试可以打开页面并断言页面标题。
但是,当我尝试运行测试时,它似乎启动和停止,甚至没有执行任何操作,甚至使用 Debug 运行。测试保持在not run 状态。
当我在{ 上设置一个断点并使用调试运行测试时,没有任何变化。它在不运行测试的情况下启动并立即停止。
测试:
[Test]
[TestCase(Browser.Chrome)]
public void ValidateWebDriverLaunches(Browser browser)
{
Driver = StaticWebDriverFactory.GetLocalWebDriver(browser);
Driver.Url = "https://example.com/";
string title = Driver.Title;
Assert.AreEqual(true, title.Contains("Example Domain"), "Title is not matching");
}
错误日志
'testhost.x86.exe' (CLR v4.0.30319: Domain 2): Unloaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
'testhost.x86.exe' (CLR v4.0.30319: Dependency finder domain): Unloaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'
The thread 0xcc has exited with code 0 (0x0).
'testhost.x86.exe' (CLR v4.0.30319: Domain 3): Unloaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
'testhost.x86.exe' (CLR v4.0.30319: Dependency finder domain): Unloaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'
The thread 0x2f90 has exited with code 0 (0x0).
The thread 0x2f80 has exited with code 0 (0x0).
The program '[8948] testhost.x86.exe' has exited with code 0 (0x0).
我已经设置了环境变量
__UNITTESTEXPLORER_VSINSTALLPATH__
指向
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE
正如一些人所建议的那样。我发现的唯一其他建议是更新 VS17,但是我使用的是 VS19,找不到有关此版本的任何信息。
【问题讨论】:
-
你用的是哪个版本的VS2019?
-
呵呵,“程序 '[8948] testhost.x86.exe' 已退出,代码为 0 (0x0)。”根据thisMS Doc页面错误代码0为“ERROR_SUCCESS”,表示成功。
-
@MindSwipe。我使用的是 16.3.0 版。这很奇怪,因为测试似乎没有运行。我没有在测试资源管理器中获得测试成功或失败。
-
奇怪,你安装了 ReSharper 吗?另外,您可以尝试右键单击您的解决方案并清理然后重建它吗?然后尝试在您的测试方法中放置一个断点并在调试模式下运行 UniTests
-
@MindSwipe 我没有 ReSharper。我在
{上设置了一个断点,并且测试不会在断点处停止。
标签: c# windows visual-studio nunit visual-studio-2019