VS 2017 15.7.1 - “旧”单元测试无法运行

时间:2018-05-14 13:44:38

标签: visual-studio unit-testing

我有一堆在VS 2015中编写的单元测试。升级到2017年时,相同的测试工作。然后我在VS 2017更新后进行了系统细分,然后我重新安装了系统和一个新的VS 2017 15.7.1。

单元测试是基本的MSTests,一些简单的测试只是调用类库中的某些类来从一些excel文件中获取数据。还有一些更复杂的,运行Selenium Webdriver并且正在执行此操作。

现在,在VS 2017 15.7.1中,所有测试都不再有效。也就是说,它们根本就没有运行。运行它们时,测试资源管理器中的进度条会正常显示正在移动的绿色,然后它会恢复为白色,测试仍显示为未运行。

将日志记录级别设置为Diagnostic时,输出为:

[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年一起安装VS 2015,这非常烦人。

(顺便说一下,有没有人知道MS在发送VS更新之前是否真的进行了任何测试?看起来像这样的bug(如果它确实是一个bug)应该是非常难以捕获的,如果你有半个qa部门。)

更新:

  1. 这与我是否在Debug或Release中运行测试无关。

  2. 这条线被认为是一个潜在的原因:
    [15.05.18 09:47:23警告]警告:MSTest V2适配器不支持testsettings文件或ForcedLegacyMode设置为true的runsettings。

  3. 但是,这是一个警告,而不是错误。删除它无论如何都没有效果。

    此外,正在使用的testsettings文件是完全默认/空的,并且没有指定参数或参数。此外,如果我想从命令行运行我的测试,这个文件在解决方案中是必需的,我必须这样做,因为我使用Excel工作表来运行和记录测试运行。但是,在VS Test Explorer中运行测试时会出现此问题;在最新的VS 2017更新中,我甚至没有从命令行运行它们。

    1. 我现在和2017年一起运行VS 2015,其解决方案版本完全相同且不变。一切正常。

1 个答案:

答案 0 :(得分:2)

我也看过这个,以下内容对我有用:

  • 创建一个名为test.runsettings的新解决方案文件(XML)(只要保留扩展名“runsettings”,就可以用任何东西替换“test”)。
  • 将示例代码从here复制到文件中。
  • 保存。清洁。重建。重启VS。

您好

不确定我之前的帖子被删除的原因。

希望有人可以帮助我而不删除我的评论: 我还没试过这个解决方案。我是新手,所以不确定为什么我们需要使用XML文件vs设置来指定平台和处理器设置?

此外,XML文件本身并不清楚 - 有很多设置,我只是不确定我是否有如何提供正确参数的所有答案。

谢谢 安德鲁