【发布时间】:2018-10-24 04:56:51
【问题描述】:
我有一堆用 VS 2015 编写的单元测试。升级到 2017 时,同样的测试工作。然后我在 VS 2017 更新后系统崩溃,然后我重新安装了系统和一个新的 VS 2017 年 15.7.1.
单元测试是基本的 MSTest,一些简单的测试只是调用类库中的一些类,这些类从一些 excel 文件中获取数据。还有一些更复杂的,运行 Selenium Webdriver 并执行此操作。
现在,在 VS 2017 15.7.1 中,所有测试都不再有效。也就是说,它们根本没有运行。运行它们时,测试资源管理器中的进度条正常显示为绿色移动,然后又变回白色,测试仍然显示为未运行。
将日志记录级别设置为诊断时的输出是这样的:
[14.05.18 15:12:50 Diagnostic] About to Enqueue operation 'RunSelectedOperation', hashcode:21607723
[14.05.18 15:12:50 Diagnostic] Enqueue operation 'RunSelectedOperation', hashcode:21607723
[14.05.18 15:12:50 Diagnostic] Operation left in the the queue: 1
[14.05.18 15:12:50 Diagnostic] 'RunSelectedOperation', hashcode:21607723
[14.05.18 15:12:50 Diagnostic]
[14.05.18 15:12:50 Diagnostic] Processing Queue .....
[14.05.18 15:12:50 Diagnostic] Operation Dequeue : 'RunSelectedOperation'
[14.05.18 15:12:50 Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=OperationSetStarted, operationInProgress=False
[14.05.18 15:12:50 Diagnostic] TestDiscoveryStats.OperationStateChanged State=OperationSetStarted, InProgress=False
[14.05.18 15:12:50 Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=ChangeDetectionStarting, operationInProgress=True
[14.05.18 15:12:50 Diagnostic] TestDiscoveryStats.OperationStateChanged State=ChangeDetectionStarting, InProgress=False
[14.05.18 15:12:50 Diagnostic] We programmatically start the build in TestWindowHost.UpdateContainer...
[14.05.18 15:12:50 Diagnostic] After we await the build that programmatically started in TestWindowHost.UpdateContainer...
[14.05.18 15:12:50 Diagnostic] TestContainer update (build) complete : 266 ms
[14.05.18 15:12:50 Diagnostic] Adding the Project in Project Map for Guid 098d9992-63a7-41c5-b5b3-6ce5e783f868
[14.05.18 15:12:50 Diagnostic] Time taken for fetching Roslyn supported projects: 0 milliseconds.
[14.05.18 15:12:50 Diagnostic] Adding the Project in Project Map for Guid 1e96f94e-161d-41eb-8546-edd8cd13aff4
[14.05.18 15:12:50 Diagnostic] Adding the Project in Project Map for Guid 3a39b466-3d4f-4a0c-b110-f045d0975713
[14.05.18 15:12:50 Diagnostic] Adding the Project in Project Map for Guid 69c4cbe6-5541-45ac-8d23-852bce725f99
[14.05.18 15:12:50 Diagnostic] Adding the Project in Project Map for Guid 1b84143e-3826-4937-8073-0d2a9b89982a
[14.05.18 15:12:50 Diagnostic] Adding the Project in Project Map for Guid e30be865-289f-4f78-8d26-9fd1802cf87b
[14.05.18 15:12:51 Diagnostic] Adding the Project in Project Map for Guid 79f803ca-528e-419f-92e8-d9df4c5624d0
[14.05.18 15:12:51 Diagnostic] Adding the Project in Project Map for Guid fe6a60de-81f3-4f58-bb72-47956957e916
[14.05.18 15:12:51 Diagnostic] Adding the Project in Project Map for Guid 36f10149-4d39-47f5-924f-726b36f30b83
[14.05.18 15:12:51 Diagnostic] test container discoverer executor://vsprojectoutputcontainerdiscoverer/v1, discovered 8 containers
[14.05.18 15:12:51 Diagnostic] Containers from 'Microsoft.VisualStudio.TestWindow.VsAdapters.VsProjectOutputContainerDiscoverer' :
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\Authentication\bin\Debug\Authentication.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\Common\bin\Debug\Common.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\FlowTests\bin\Debug\FlowTests.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\Opus3TestAutomation\bin\Debug\Opus3TestAutomation.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\OpusAutomation\bin\Debug\OpusAutomation.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\OpusResources\bin\Debug\OpusResources.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\OpusTests\bin\Debug\OpusTests.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] C:\Source\Workspaces\QA\Opus3TestAutomation\TestData\bin\Debug\TestData.dll:executor://vsprojectoutputcontainerdiscoverer/v1
[14.05.18 15:12:51 Diagnostic] test container discoverer executor://testexplorerservicecontainerdiscoverer/v1, discovered 0 containers
[14.05.18 15:12:51 Diagnostic] No containers found from 'Microsoft.VisualStudio.TestWindow.Extensibility.TestExplorerServiceContainerDiscoverer' :
[14.05.18 15:12:51 Diagnostic] test container discoverer executor://cpsprojectoutputtestcontainerdiscoverer/v2, discovered 0 containers
[14.05.18 15:12:51 Diagnostic] No containers found from 'Microsoft.VisualStudio.TestWindow.Extensions.CPSTestContainerDiscoverer' :
[14.05.18 15:12:51 Diagnostic] test container discoverer executor://powershelltestexecutor/v1, discovered 0 containers
[14.05.18 15:12:51 Diagnostic] No containers found from 'PowerShellTools.TestAdapter.PowerShellTestContainerDiscoverer' :
[14.05.18 15:12:51 Diagnostic] test container discoverer executor://orderedtestadapter/v1, discovered 0 containers
[14.05.18 15:12:51 Diagnostic] No containers found from 'Microsoft.VisualStudio.MSTest.TestWindow.OrderedTestContainerDiscoverer' :
[14.05.18 15:12:51 Diagnostic] test container discoverer executor://generictestadapter/v1, discovered 0 containers
[14.05.18 15:12:51 Diagnostic] No containers found from 'Microsoft.VisualStudio.MSTest.TestWindow.GenericTestContainerDiscoverer' :
[14.05.18 15:12:51 Diagnostic] test container discoverer executor://webtestadapter/v1, discovered 0 containers
[14.05.18 15:12:51 Diagnostic] No containers found from 'Microsoft.VisualStudio.MSTest.TestWindow.WebTestContainerDiscoverer' :
[14.05.18 15:12:51 Diagnostic] DiscoveryOperation<RunSelectedOperation> FinishedChangedCotainers, changed container count is 0
[14.05.18 15:12:51 Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=ChangeDetectionFinished, operationInProgress=False
[14.05.18 15:12:51 Diagnostic] TestDiscoveryStats.OperationStateChanged State=ChangeDetectionFinished, InProgress=False
[14.05.18 15:12:51 Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=TestExecutionStarting, operationInProgress=False
[14.05.18 15:12:51 Diagnostic] TestDiscoveryStats.OperationStateChanged State=TestExecutionStarting, InProgress=False
[14.05.18 15:12:51 Informational] ------ Run test started ------
[14.05.18 15:12:51 Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=TestExecutionStarted, operationInProgress=False
[14.05.18 15:12:51 Diagnostic] TestDiscoveryStats.OperationStateChanged State=TestExecutionStarted, InProgress=False
[14.05.18 15:12:51 Diagnostic] RunSettings Content:
<RunSettings>
<RunConfiguration>
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
<ResultsDirectory>C:\Source\Workspaces\QA\
Opus3TestAutomation\TestResults</ResultsDirectory>
<SolutionDirectory>C:\Source\Workspaces\QA\Opus3TestAutomation\
</SolutionDirectory>
<TargetPlatform>X86</TargetPlatform>
</RunConfiguration>
<MSTest>
<SettingsFile>C:\Source\Workspaces\QA\Opus3TestAutomation\
Opus3TestAutomation.testsettings</SettingsFile>
<ForcedLegacyMode>true</ForcedLegacyMode>
<IgnoreTestImpact>true</IgnoreTestImpact>
</MSTest>
</RunSettings>
[14.05.18 15:12:51 Diagnostic] Final RunSettings for the current TestRunCriteria:
<RunSettings>
<RunConfiguration>
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
<ResultsDirectory>C:\Source\Workspaces\QA\
Opus3TestAutomation\TestResults</ResultsDirectory>
<SolutionDirectory>C:\Source\Workspaces\QA\Opus3TestAutomation\
</SolutionDirectory>
<TargetPlatform>X86</TargetPlatform>
<CollectSourceInformation>False</CollectSourceInformation>
</RunConfiguration>
<MSTest>
<SettingsFile>C:\Source\Workspaces\QA\
Opus3TestAutomation\Opus3TestAutomation.testsettings</SettingsFile>
<ForcedLegacyMode>true</ForcedLegacyMode>
<IgnoreTestImpact>true</IgnoreTestImpact>
</MSTest>
</RunSettings>
[14.05.18 15:12:53 Warning] Warning : A testsettings file or a runsettings with a ForcedLegacyMode set to true is not supported with the MSTest V2 Adapter.
[14.05.18 15:12:53 Warning] No test is available in C:\Source\Workspaces\QA\Opus3TestAutomation\FlowTests\bin\Debug\FlowTests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[14.05.18 15:12:53 Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=OperationSetFinished, operationInProgress=False
[14.05.18 15:12:53 Diagnostic] TestDiscoveryStats.OperationStateChanged State=OperationSetFinished, InProgress=False
[14.05.18 15:12:53 Diagnostic] *** Run finished using 'InMemoryUnitTestWriter' ***
[14.05.18 15:12:53 Informational] ========== Run test finished: 0 run (0:00:02,1963655) ==========
[14.05.18 15:12:53 Diagnostic] VirtualReadOnlyTestDataStore.OperationStateChanged State=TestExecutionFinished, operationInProgress=False
[14.05.18 15:12:53 Diagnostic] TestDiscoveryStats.OperationStateChanged State=TestExecutionFinished, InProgress=False
显然,VS 没有找到任何测试,即使测试已在测试资源管理器中列出。
这似乎也是不时更新的问题;我已经看到它在更新后至少在 VS 2015 和 2017 中被提及。不过,我还没有找到一个明智的解决方案。必须在 2017 和 2017 旁边安装 VS 2015 只是为了能够做一些像运行我的单元测试这样基本的事情,这非常烦人。
(顺便说一句,有没有人知道 MS 在发布 VS 更新之前是否真的做了任何测试?看起来像这样的错误(如果它确实是一个错误)如果你有的话应该很难不被发现半个 QA 部门)
更新:
这与我是在 Debug 还是 Release 中运行测试无关。
已建议将此行作为潜在原因:
[15.05.18 09:47:23 警告] 警告:MSTest V2 适配器不支持将 ForcedLegacyMode 设置为 true 的 testsettings 文件或 runsettings。
但是,这是一个警告,而不是错误。删除它没有任何效果。
此外,正在使用的 testsettings 文件是完全默认/空的,并且没有指定参数或参数。此外,如果我想从命令行运行测试,则此文件在解决方案中是必需的,因为我使用 Excel 工作表来运行和记录测试运行,所以我必须这样做。但是,在 VS 测试资源管理器中运行测试时会出现此问题;在最新的 VS 2017 更新中,我什至还没有从命令行运行它们。
- 我现在正在运行 VS 2015 和 2017,使用完全相同且未更改的解决方案版本。在这里,一切正常。
【问题讨论】:
-
您收到一条警告说您的设置不受支持...您对此做了什么吗?也许使用不同的设置运行?
-
抱歉,忘记说明了。不,我没有更改任何设置。 testsettings 文件是我创建的一个文件,从未在其中设置任何值,因为它需要能够从 VS 命令控制台运行测试。
-
还需要吗?因为警告说它不受支持。也许删除/重命名它,看看会发生什么?
-
您必须首先在谷歌上搜索“mstest 没有可用的测试”,这样我们就不必在此处重复现有 Q+A 已经涵盖的许多已知原因。也许值得注意的是,尝试从 bin\Debug 运行测试是有问题的。
-
我有,但我没有找到任何有效的方法。此外,很多信息已有多年历史,我认为 VS 2015 或更早版本的修复/解决方案可能与最新的 VS 2017 无关?尤其是考虑到问题是从最新版本开始的。当然,我会继续寻找。但这是一个正常工作的情况,然后突然因更新而中断。 VS 2017 显然可以看到测试,因为我试图从测试资源管理器中运行它们。我正在并行运行 VS 2015,同样的测试在这里运行良好。
标签: visual-studio unit-testing