错误:VS2017 Live Unit Testing - 只有减号 - 不起作用
Bug: VS2017 Live Unit Testing - only minus's - doesn't work
TL;DR;编辑 6: 我已经缩小范围并提供了 5 个步骤来重现 problem/bug。
- 创建 VS2017 c# 控制台应用程序(.Net 完整框架)
- 添加一个方法到Program.cs并使classpublic:
public class Program
{
static void Main(string[] args)
{
}
public int Add(int a, int b)
{
return a + b;
}
}
}
- 右键单击
Add
方法并选择创建单元测试:
- 使用这些设置通过测试创建一个新的单元测试项目:
- 添加单元测试
[TestMethod()]
public void AddTest()
{
Program p = new Program();
var r = p.Add(1, 2);
Assert.IsTrue(3 == r);
}
- 测试菜单 > 实时单元测试 > 开始
AddTest()
> 实时测试 > 包含的上下文菜单
现在将Add的+符号改为-
实时单元测试有效,将 - 符号改回 + 并且实时测试通过!
现在添加对 Nuget DLL 的引用(任何人都会这样做)- 实时单元测试不再有效!或者干脆关闭解决方案,重新打开它,Live Unit Testing 不再有效!
我已经设置了一个 MSUnitTest v2 项目并开始了实时单元测试。我正在使用 Web Api 2 .Net 项目(完整框架 v4.5.2)。
我到处都看到减号,但没有勾号或叉号。
我更改了代码,就像他们在 Live Unit Testing in Visual Studio 2017 video 中所做的那样,时钟出现在减号上,但随后什么都没有...
调试单元测试会通过:
当我将鼠标悬停在蓝色减号上时,消息是 "Covered by 0 Tests"
我发现您需要 MSTest.TestAdapter 和 MSTest.TestFramework 根据 https://developercommunity.visualstudio.com/content/problem/5520/live-unit-test-are-only-showing-minuses-using-micr.html我已经完成并引用了 V1.18:
- Microsoft.VisualStudio.TestPlatform.TestFramework
- Microsoft.VisualStudio.TestPlatform.TestFramework.扩展
有一群 Beta 测试人员报告了同样的问题:
https://developercommunity.visualstudio.com/content/problem/4376/live-unit-testing-doesnt-work.html
所有帖子都已解决或不会修复。
此 Whosebug user got an issue with Live Unit Testing but its a Null Exception problem. I tried the solution in comments 用于从 Gac 中删除 Microsoft.VisualStudio.QualityTools.UnitTestFramework,当我尝试从 C:\Windows\assembly 卸载时,我的访问被拒绝并通过开发人员命令提示进行卸载:
GacUtil /u Microsoft.VisualStudio.QualityTools.UnitTestFramework
结果:
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
Unable to uninstall: assembly is required by one or more applications
有人可以帮助我进行实时单元测试吗?
编辑 1:
在 VS > 工具 > 选项 > 实时单元测试中,我将日志记录设置为详细。
查看输出我看到一个警告:
[15:48:26.521 Verbose] - TestDriver - TestDiscoverer log message: Warning - Configuration system failed to initialize
根据 this 中的一些答案,我仍然无法摆脱 "Configuration system failed to initialize" - 不确定这是否是误导,这是我唯一的线索'目前已经找到...
编辑 2:
我 运行 VS2017 作为管理员并且摆脱了 "Configuration system failed to initialize"。不幸的是 运行 宁因为管理员没有什么不同,它仍然不起作用但没有失败,没有任何例外。
这是详细日志。有趣的是 "Preparing to start test discovery" 看起来它找到了我包含的 x86 测试。
但是,它显然无法发现测试; "Discovered 0 tests"
[16:52:55.110 Verbose] - Aggregator - Calculating the set of tests that cover 1 files
[16:52:55.110 Verbose] - Aggregator - [Workflow 4] Sending TestRequestEvent with 6 assemblies and 0 tests
[16:52:55.110 Verbose] - TestDriver - [Workflow 4] Received TestRequestEvent
[16:52:55.110 Verbose] - TestDriver - [Workflow 4] Preparing to start test discovery (X64: 0, X86: 1).
[16:52:55.110 Verbose] - TestDriver - [Workflow 4] Start discovering tests from group 0, which contains 1 assemblies.
[16:52:55.599 Verbose] - TestDriver - [Workflow 4] Finished discovering test from group 0.
[16:52:55.599 Verbose] - TestDriver - [Workflow 4] Discovered 0 tests from XYZ.API.ClientService\bin\Debug\XYZ.API.ClientService.dll, updating cached data.
[16:52:55.599 Verbose] - TestDriver - [Workflow 4] Notify Aggregator about completion of test run. (Passed: 0, Failed: 0, Run succeeded: True)
[16:52:55.599 Verbose] - Aggregator - [Workflow 4] Received TestResponseEvent (TestRunCompleted)
[16:52:55.599 Verbose] - Aggregator - [Workflow 4] Coverage data for 0 tests was received during this workflow
[16:52:55.600 Verbose] - BuildManager - Allow to send a single build event.
[16:52:55.599 Verbose] - Aggregator - Starting coverage aggregation cycle - work list has 3 methods
[16:52:55.599 Verbose] - Aggregator - Finished coverage aggregation cycle - work list had 3 methods of which 3 methods were defined in 2 open files
[16:52:55.600 Verbose] - BuildManager - Interrupting build queue -> no new assemblies.
[16:52:55.600 Verbose] - StatusMargin - Received file coverage result
[16:52:55.599 Verbose] - Aggregator - Sending FileCoverageResult for 'C:\XYZProjectCollection\XYZ\XYZ.API.ClientService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.ClientService\XYZ.API.MiscService.csproj'
[16:52:55.599 Verbose] - Aggregator - [Workflow 4] Sending TestRunCompletedEvent
编辑 3:
我今天查看了 ProcessMonitor 跟踪记录。没有什么特别突出的地方,我可能漏掉了一些东西,但我开始觉得这是一个错误,而不是配置问题。
我在一个非常封闭的环境中工作,所以可能是在 vs2017 安装过程中某些东西被阻止了。我知道 Unity3D 域未列入下载白名单。尽管安装了所有核心 Visual Studio Microsoft 东西。我开始 运行 脱离诊断故障排除策略。非常欢迎任何想法!
编辑 4:
今天早上我决定从 GAC 中删除 Microsoft.VisualStudio.QualityTools.UnitTestFramework
DLL。我是按照 these instructions to overcome the Access Denied:
做的
这导致找到了潜在的根本原因之一。我开始看到实时单元测试日志输出:
[09:44:59.053 Verbose] - BuildManager - C:\Program Files x86\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3245,5): error MSB3491: Could not write lines to file "C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\CoreCompileInputs.cache". Access to the path 'C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\CoreCompileInputs.cache' is denied.
[09:44:59.053 Verbose] - BuildManager - C:\Program Files x86\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(4874,5): error MSB3491: Could not write lines to file "C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\XYZ.API.MiscService.csproj.FileListAbsolute.txt". Access to the path 'C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\XYZ.API.MiscService.csproj.FileListAbsolute.txt' is denied.
我给了自己所有这些目录的权限,只是为了排除任何权限问题:
这仍然不起作用,但是我似乎越来越接近实时单元测试需要更长的时间才能不工作(即出现在顶部的时钟的减号需要更长的时间来处理)。
然后我再次尝试 ProcMon,它显示了一些有趣的日志,但没有确凿的证据。
这是当前的详细日志:
[10:22:07.363 Info] - BuildManager - Build completed (succeeded).
[10:22:07.363 Verbose] - BuildManager - Interrupting build queue -> switching 'build' and 'test' directories.
[10:22:07.363 Verbose] - BuildManager - New 'test' directory: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\
[10:22:07.363 Verbose] - BuildManager - New 'build' directory: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528[=15=]\
[10:22:07.363 Verbose] - Aggregator - [Workflow 4] Received BuildEvent.
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Tests\bin\Debug\XYZ.API.Tests.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.AccountClientService\bin\Debug\XYZ.API.AccountClientService.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API\bin\XYZ.API.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Helpers\bin\Debug\XYZ.API.Global.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.MiscService\bin\Debug\XYZ.API.MiscService.dll
[10:22:07.363 Verbose] - Aggregator - file: 'C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj'
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Tests\bin\Debug\XYZ.API.Tests.dll with MVID c96c0f4b-b21e-47be-a71e-97ebf8a3d493 since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.AccountClientService\bin\Debug\XYZ.API.AccountClientService.dll with MVID 6772f896-04ab-4804-bb18-3ed2c7aeb9b9 since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API\bin\XYZ.API.dll with MVID 9c862440-c16a-4efe-8574-76e8c1453c4d since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Helpers\bin\Debug\XYZ.API.Global.dll with MVID a8899d5d-4730-46bf-b4f2-3c2b1b75b0b1 since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Removing MVID f337ca44-aae6-42ca-8df5-3776ff962372 for project C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj from the file span cache
[10:22:07.363 Verbose] - Aggregator - Adding MVID 8e944276-0eec-43f4-aff3-07e40f8611dc for project C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj to the file span cache
[10:22:07.363 Verbose] - Aggregator - Calculating the set of tests that cover 0 files
[10:22:07.363 Verbose] - Aggregator - Reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.MiscService\bin\Debug\XYZ.API.MiscService.dll with MVID 8e944276-0eec-43f4-aff3-07e40f8611dc
[10:22:07.363 Verbose] - Aggregator - Adding 3 methods from 'C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj' to the coverage aggregation work list
[10:22:07.363 Verbose] - Aggregator - Calculating the set of tests that cover 1 files
[10:22:07.363 Verbose] - Aggregator - [Workflow 4] Sending TestRequestEvent with 5 assemblies and 0 tests
[10:22:07.363 Verbose] - TestDriver - [Workflow 4] Received TestRequestEvent
[10:22:07.363 Verbose] - TestDriver - [Workflow 4] Preparing to start test discovery (X64: 0, X86: 1).
[10:22:07.363 Verbose] - TestDriver - [Workflow 4] Start discovering tests from group 0, which contains 1 assemblies.
[10:22:07.834 Verbose] - TestDriver - [Workflow 4] Finished discovering test from group 0.
[10:22:07.834 Verbose] - TestDriver - [Workflow 4] Discovered 0 tests from XYZ.API.MiscService\bin\Debug\XYZ.API.MiscService.dll, updating cached data.
[10:22:07.834 Verbose] - TestDriver - [Workflow 4] Notify Aggregator about completion of test run. (Passed: 0, Failed: 0, Run succeeded: True)
[10:22:07.834 Verbose] - Aggregator - [Workflow 4] Received TestResponseEvent (TestRunCompleted)
[10:22:07.834 Verbose] - Aggregator - [Workflow 4] Coverage data for 0 tests was received during this workflow
[10:22:07.834 Verbose] - Aggregator - Starting coverage aggregation cycle - work list has 3 methods
[10:22:07.834 Verbose] - Aggregator - Finished coverage aggregation cycle - work list had 3 methods of which 3 methods were defined in 5 open files
[10:22:07.834 Verbose] - BuildManager - Allow to send a single build event.
[10:22:07.834 Verbose] - BuildManager - Interrupting build queue -> no new assemblies.
[10:22:07.834 Verbose] - Aggregator - Sending FileCoverageResult for 'C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj'
[10:22:07.834 Verbose] - Aggregator - [Workflow 4] Sending TestRunCompletedEvent
[10:22:07.850 Verbose] - StatusMargin - Received file coverage result
编辑 5:
问:为什么我在实时测试集中包含或排除测试后没有任何反应?
答:这是一个已知问题,我们无法在 Visual Studio 2017 版本 15.0 中修复。现在已在 Visual Studio 2017 版本 15.2 中修复。
原来我有 Visual Studio/15.0.0 +26228.9。升级到 Visual Studio 2017 (v15.2) 不能 解决问题。
我已将此问题报告给 https://developercommunity.visualstudio.com 并将及时通知大家。它没有正确地报告环境被锁定。
更新: MS 说它已在 15.3.2
中修复
好的,我已经缩小范围了。
当您将 NuGet 引用添加到单元测试项目时,它会在某些情况下添加 packages.config AND 可能 添加一个 App.Config 文件。
当我添加 Oracle.ManagedDataAccess 时,将以下内容添加到 App.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--<configSections>
<section name="oracle.manageddataaccess.client"
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</configSections>-->
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client"/>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<publisherPolicy apply="no"/>
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
<bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
</dataSources>
</version>
</oracle.manageddataaccess.client>
</configuration>
请注意我是如何注释掉 的,纯粹是通过消除过程我发现它是这个特定的 App.Config 导致实时单元测试失败的标记。
正如其他人所提到的,此功能仍然存在一些问题。我的运气还算不错,只是打开了这个功能,并关注了测试资源管理器 window - 至少在我的盒子上,它运行了测试,即使 "minus signs" 在代码编辑器的排水沟。但是,我已经看到该功能正常工作。
我会继续使用该功能,并继续以任何可能的方式向 Microsoft 提供反馈(Visual Studio 菜单栏中应该有一个“发送反馈”按钮)。
更新:
使用现有项目,我在编辑器的装订线中根本看不到 UI ...我安装了 15.3.4 版。我在实时单元测试中包含了一个完整的解决方案,然后重建...我在输出中收到此消息 window:
[11:42:17.584 Info] No supported test adapters are referenced by this solution. If you have a test project, add a NuGet reference to a test adapter corresponding to the test framework used in order to run the tests. If you already have the required NuGet reference in your test project, performing a NuGet restore may resolve the issue.
更新 2:
创建一个新项目作为测试用例,并按照您的步骤包含一个添加了 configsections 标记的 NuGet 包,我能够重现该问题。希望这不会增加混乱,但我只有排除的 tests/minus 标志问题 当 configsections 标记被注释掉(并且安装了 Oracle 包)时。
我认为这个功能很棒,而且运行良好。然而不是那么新(参见:http://www.ncrunch.net/)。
它还有一个问题,我刚刚 运行 解决了这个问题。这与您遇到的问题非常相似。你有多个单元测试项目吗?如果是,那么您应该检查整个解决方案的 Nuget 包。右键单击解决方案并单击 "Mange Nuget packages for Solution..."
检查 "Consolidate" 选项卡并确保在每个测试项目上安装了 相同版本:
- MSTest.TestAdapter
- MSTest.TestFramewor
这是错误设置的屏幕截图,这将导致整个 Live 单元测试功能失败。
将所有项目更新为同一版本后,它应该可以正常工作。但只是为了确定:
- 重启VS
- 开始实时单元测试之前:转到您的项目文件夹 .vs\\lut,您可以删除整个 LUT(实时单元测试)文件夹。它可能包含无效的缓存数据。
希望对您有所帮助。
我在使用 v15.5.6 时遇到了同样的问题。我发现解决方案是去
工具 |实时单元测试 |删除持久数据。
我确实遇到了这个问题,并且能够通过更新到 visual studio 15.7.3 并选择测试 > Live Unit Testing > 选项 - 然后 运行 [=12 来解决这个问题=].
我在一个简单的解决方案中遇到了同样的问题,其中包括一个 class 库项目和一个测试项目。显然,我的测试项目被排除在实时单元测试之外。包含项目后(右键单击项目 > Live Unit Testing > Include)图标工作正常。虽然这为我解决了问题,但我真的不清楚在我的测试 classes 中的每一行代码上都有实时测试图标的价值是什么。
我相信您已经找到了问题所在,但就我而言,帮助简单地安装 Microsoft.NET.Test.Sdk。确保将其添加到测试项目中。我花了几天时间尝试解决这个问题,就这么简单。
TL;DR;编辑 6: 我已经缩小范围并提供了 5 个步骤来重现 problem/bug。
- 创建 VS2017 c# 控制台应用程序(.Net 完整框架)
- 添加一个方法到Program.cs并使classpublic:
public class Program
{
static void Main(string[] args)
{
}
public int Add(int a, int b)
{
return a + b;
}
}
}
- 右键单击
Add
方法并选择创建单元测试:
- 使用这些设置通过测试创建一个新的单元测试项目:
- 添加单元测试
[TestMethod()]
public void AddTest()
{
Program p = new Program();
var r = p.Add(1, 2);
Assert.IsTrue(3 == r);
}
- 测试菜单 > 实时单元测试 > 开始
AddTest()
> 实时测试 > 包含的上下文菜单
现在将Add的+符号改为-
实时单元测试有效,将 - 符号改回 + 并且实时测试通过!
现在添加对 Nuget DLL 的引用(任何人都会这样做)- 实时单元测试不再有效!或者干脆关闭解决方案,重新打开它,Live Unit Testing 不再有效!
我已经设置了一个 MSUnitTest v2 项目并开始了实时单元测试。我正在使用 Web Api 2 .Net 项目(完整框架 v4.5.2)。
我到处都看到减号,但没有勾号或叉号。
我更改了代码,就像他们在 Live Unit Testing in Visual Studio 2017 video 中所做的那样,时钟出现在减号上,但随后什么都没有...
调试单元测试会通过:
当我将鼠标悬停在蓝色减号上时,消息是 "Covered by 0 Tests"
我发现您需要 MSTest.TestAdapter 和 MSTest.TestFramework 根据 https://developercommunity.visualstudio.com/content/problem/5520/live-unit-test-are-only-showing-minuses-using-micr.html我已经完成并引用了 V1.18:
- Microsoft.VisualStudio.TestPlatform.TestFramework
- Microsoft.VisualStudio.TestPlatform.TestFramework.扩展
有一群 Beta 测试人员报告了同样的问题:
https://developercommunity.visualstudio.com/content/problem/4376/live-unit-testing-doesnt-work.html
所有帖子都已解决或不会修复。
此 Whosebug user got an issue with Live Unit Testing but its a Null Exception problem. I tried the solution in comments 用于从 Gac 中删除 Microsoft.VisualStudio.QualityTools.UnitTestFramework,当我尝试从 C:\Windows\assembly 卸载时,我的访问被拒绝并通过开发人员命令提示进行卸载:
GacUtil /u Microsoft.VisualStudio.QualityTools.UnitTestFramework
结果:
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL Unable to uninstall: assembly is required by one or more applications
有人可以帮助我进行实时单元测试吗?
编辑 1:
在 VS > 工具 > 选项 > 实时单元测试中,我将日志记录设置为详细。
查看输出我看到一个警告:
[15:48:26.521 Verbose] - TestDriver - TestDiscoverer log message: Warning - Configuration system failed to initialize
根据 this 中的一些答案,我仍然无法摆脱 "Configuration system failed to initialize" - 不确定这是否是误导,这是我唯一的线索'目前已经找到...
编辑 2:
我 运行 VS2017 作为管理员并且摆脱了 "Configuration system failed to initialize"。不幸的是 运行 宁因为管理员没有什么不同,它仍然不起作用但没有失败,没有任何例外。
这是详细日志。有趣的是 "Preparing to start test discovery" 看起来它找到了我包含的 x86 测试。
但是,它显然无法发现测试; "Discovered 0 tests"
[16:52:55.110 Verbose] - Aggregator - Calculating the set of tests that cover 1 files
[16:52:55.110 Verbose] - Aggregator - [Workflow 4] Sending TestRequestEvent with 6 assemblies and 0 tests
[16:52:55.110 Verbose] - TestDriver - [Workflow 4] Received TestRequestEvent
[16:52:55.110 Verbose] - TestDriver - [Workflow 4] Preparing to start test discovery (X64: 0, X86: 1).
[16:52:55.110 Verbose] - TestDriver - [Workflow 4] Start discovering tests from group 0, which contains 1 assemblies.
[16:52:55.599 Verbose] - TestDriver - [Workflow 4] Finished discovering test from group 0.
[16:52:55.599 Verbose] - TestDriver - [Workflow 4] Discovered 0 tests from XYZ.API.ClientService\bin\Debug\XYZ.API.ClientService.dll, updating cached data.
[16:52:55.599 Verbose] - TestDriver - [Workflow 4] Notify Aggregator about completion of test run. (Passed: 0, Failed: 0, Run succeeded: True)
[16:52:55.599 Verbose] - Aggregator - [Workflow 4] Received TestResponseEvent (TestRunCompleted)
[16:52:55.599 Verbose] - Aggregator - [Workflow 4] Coverage data for 0 tests was received during this workflow
[16:52:55.600 Verbose] - BuildManager - Allow to send a single build event.
[16:52:55.599 Verbose] - Aggregator - Starting coverage aggregation cycle - work list has 3 methods
[16:52:55.599 Verbose] - Aggregator - Finished coverage aggregation cycle - work list had 3 methods of which 3 methods were defined in 2 open files
[16:52:55.600 Verbose] - BuildManager - Interrupting build queue -> no new assemblies.
[16:52:55.600 Verbose] - StatusMargin - Received file coverage result
[16:52:55.599 Verbose] - Aggregator - Sending FileCoverageResult for 'C:\XYZProjectCollection\XYZ\XYZ.API.ClientService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.ClientService\XYZ.API.MiscService.csproj'
[16:52:55.599 Verbose] - Aggregator - [Workflow 4] Sending TestRunCompletedEvent
编辑 3:
我今天查看了 ProcessMonitor 跟踪记录。没有什么特别突出的地方,我可能漏掉了一些东西,但我开始觉得这是一个错误,而不是配置问题。
我在一个非常封闭的环境中工作,所以可能是在 vs2017 安装过程中某些东西被阻止了。我知道 Unity3D 域未列入下载白名单。尽管安装了所有核心 Visual Studio Microsoft 东西。我开始 运行 脱离诊断故障排除策略。非常欢迎任何想法!
编辑 4:
今天早上我决定从 GAC 中删除 Microsoft.VisualStudio.QualityTools.UnitTestFramework
DLL。我是按照 these instructions to overcome the Access Denied:
这导致找到了潜在的根本原因之一。我开始看到实时单元测试日志输出:
[09:44:59.053 Verbose] - BuildManager - C:\Program Files x86\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3245,5): error MSB3491: Could not write lines to file "C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\CoreCompileInputs.cache". Access to the path 'C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\CoreCompileInputs.cache' is denied.
[09:44:59.053 Verbose] - BuildManager - C:\Program Files x86\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(4874,5): error MSB3491: Could not write lines to file "C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\XYZ.API.MiscService.csproj.FileListAbsolute.txt". Access to the path 'C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\i\XYZ.API.MiscService\Debug\XYZ.API.MiscService.csproj.FileListAbsolute.txt' is denied.
我给了自己所有这些目录的权限,只是为了排除任何权限问题:
这仍然不起作用,但是我似乎越来越接近实时单元测试需要更长的时间才能不工作(即出现在顶部的时钟的减号需要更长的时间来处理)。
然后我再次尝试 ProcMon,它显示了一些有趣的日志,但没有确凿的证据。
这是当前的详细日志:
[10:22:07.363 Info] - BuildManager - Build completed (succeeded).
[10:22:07.363 Verbose] - BuildManager - Interrupting build queue -> switching 'build' and 'test' directories.
[10:22:07.363 Verbose] - BuildManager - New 'test' directory: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\
[10:22:07.363 Verbose] - BuildManager - New 'build' directory: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528[=15=]\
[10:22:07.363 Verbose] - Aggregator - [Workflow 4] Received BuildEvent.
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Tests\bin\Debug\XYZ.API.Tests.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.AccountClientService\bin\Debug\XYZ.API.AccountClientService.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API\bin\XYZ.API.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Helpers\bin\Debug\XYZ.API.Global.dll
[10:22:07.363 Verbose] - Aggregator - assembly: C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.MiscService\bin\Debug\XYZ.API.MiscService.dll
[10:22:07.363 Verbose] - Aggregator - file: 'C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj'
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Tests\bin\Debug\XYZ.API.Tests.dll with MVID c96c0f4b-b21e-47be-a71e-97ebf8a3d493 since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.AccountClientService\bin\Debug\XYZ.API.AccountClientService.dll with MVID 6772f896-04ab-4804-bb18-3ed2c7aeb9b9 since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API\bin\XYZ.API.dll with MVID 9c862440-c16a-4efe-8574-76e8c1453c4d since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Skip reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.Helpers\bin\Debug\XYZ.API.Global.dll with MVID a8899d5d-4730-46bf-b4f2-3c2b1b75b0b1 since we already have this information from a previous build
[10:22:07.363 Verbose] - Aggregator - Removing MVID f337ca44-aae6-42ca-8df5-3776ff962372 for project C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj from the file span cache
[10:22:07.363 Verbose] - Aggregator - Adding MVID 8e944276-0eec-43f4-aff3-07e40f8611dc for project C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj to the file span cache
[10:22:07.363 Verbose] - Aggregator - Calculating the set of tests that cover 0 files
[10:22:07.363 Verbose] - Aggregator - Reading spans for assembly C:\XYZProjectCollection\Lincoln\.vs\XYZ.API528\t\XYZ.API.MiscService\bin\Debug\XYZ.API.MiscService.dll with MVID 8e944276-0eec-43f4-aff3-07e40f8611dc
[10:22:07.363 Verbose] - Aggregator - Adding 3 methods from 'C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj' to the coverage aggregation work list
[10:22:07.363 Verbose] - Aggregator - Calculating the set of tests that cover 1 files
[10:22:07.363 Verbose] - Aggregator - [Workflow 4] Sending TestRequestEvent with 5 assemblies and 0 tests
[10:22:07.363 Verbose] - TestDriver - [Workflow 4] Received TestRequestEvent
[10:22:07.363 Verbose] - TestDriver - [Workflow 4] Preparing to start test discovery (X64: 0, X86: 1).
[10:22:07.363 Verbose] - TestDriver - [Workflow 4] Start discovering tests from group 0, which contains 1 assemblies.
[10:22:07.834 Verbose] - TestDriver - [Workflow 4] Finished discovering test from group 0.
[10:22:07.834 Verbose] - TestDriver - [Workflow 4] Discovered 0 tests from XYZ.API.MiscService\bin\Debug\XYZ.API.MiscService.dll, updating cached data.
[10:22:07.834 Verbose] - TestDriver - [Workflow 4] Notify Aggregator about completion of test run. (Passed: 0, Failed: 0, Run succeeded: True)
[10:22:07.834 Verbose] - Aggregator - [Workflow 4] Received TestResponseEvent (TestRunCompleted)
[10:22:07.834 Verbose] - Aggregator - [Workflow 4] Coverage data for 0 tests was received during this workflow
[10:22:07.834 Verbose] - Aggregator - Starting coverage aggregation cycle - work list has 3 methods
[10:22:07.834 Verbose] - Aggregator - Finished coverage aggregation cycle - work list had 3 methods of which 3 methods were defined in 5 open files
[10:22:07.834 Verbose] - BuildManager - Allow to send a single build event.
[10:22:07.834 Verbose] - BuildManager - Interrupting build queue -> no new assemblies.
[10:22:07.834 Verbose] - Aggregator - Sending FileCoverageResult for 'C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\Repositories\ValueRepository.cs - C:\XYZProjectCollection\Lincoln\XYZ.API.MiscService\XYZ.API.MiscService.csproj'
[10:22:07.834 Verbose] - Aggregator - [Workflow 4] Sending TestRunCompletedEvent
[10:22:07.850 Verbose] - StatusMargin - Received file coverage result
编辑 5:
问:为什么我在实时测试集中包含或排除测试后没有任何反应?
答:这是一个已知问题,我们无法在 Visual Studio 2017 版本 15.0 中修复。现在已在 Visual Studio 2017 版本 15.2 中修复。
原来我有 Visual Studio/15.0.0 +26228.9。升级到 Visual Studio 2017 (v15.2) 不能 解决问题。
我已将此问题报告给 https://developercommunity.visualstudio.com 并将及时通知大家。它没有正确地报告环境被锁定。
更新: MS 说它已在 15.3.2
中修复好的,我已经缩小范围了。
当您将 NuGet 引用添加到单元测试项目时,它会在某些情况下添加 packages.config AND 可能 添加一个 App.Config 文件。
当我添加 Oracle.ManagedDataAccess 时,将以下内容添加到 App.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--<configSections>
<section name="oracle.manageddataaccess.client"
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</configSections>-->
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client"/>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<publisherPolicy apply="no"/>
<assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
<bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.122.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
</dataSources>
</version>
</oracle.manageddataaccess.client>
</configuration>
请注意我是如何注释掉 的,纯粹是通过消除过程我发现它是这个特定的 App.Config 导致实时单元测试失败的标记。
正如其他人所提到的,此功能仍然存在一些问题。我的运气还算不错,只是打开了这个功能,并关注了测试资源管理器 window - 至少在我的盒子上,它运行了测试,即使 "minus signs" 在代码编辑器的排水沟。但是,我已经看到该功能正常工作。
我会继续使用该功能,并继续以任何可能的方式向 Microsoft 提供反馈(Visual Studio 菜单栏中应该有一个“发送反馈”按钮)。
更新:
使用现有项目,我在编辑器的装订线中根本看不到 UI ...我安装了 15.3.4 版。我在实时单元测试中包含了一个完整的解决方案,然后重建...我在输出中收到此消息 window:
[11:42:17.584 Info] No supported test adapters are referenced by this solution. If you have a test project, add a NuGet reference to a test adapter corresponding to the test framework used in order to run the tests. If you already have the required NuGet reference in your test project, performing a NuGet restore may resolve the issue.
更新 2: 创建一个新项目作为测试用例,并按照您的步骤包含一个添加了 configsections 标记的 NuGet 包,我能够重现该问题。希望这不会增加混乱,但我只有排除的 tests/minus 标志问题 当 configsections 标记被注释掉(并且安装了 Oracle 包)时。
我认为这个功能很棒,而且运行良好。然而不是那么新(参见:http://www.ncrunch.net/)。
它还有一个问题,我刚刚 运行 解决了这个问题。这与您遇到的问题非常相似。你有多个单元测试项目吗?如果是,那么您应该检查整个解决方案的 Nuget 包。右键单击解决方案并单击 "Mange Nuget packages for Solution..." 检查 "Consolidate" 选项卡并确保在每个测试项目上安装了 相同版本:
- MSTest.TestAdapter
- MSTest.TestFramewor
这是错误设置的屏幕截图,这将导致整个 Live 单元测试功能失败。
将所有项目更新为同一版本后,它应该可以正常工作。但只是为了确定:
- 重启VS
- 开始实时单元测试之前:转到您的项目文件夹 .vs\\lut,您可以删除整个 LUT(实时单元测试)文件夹。它可能包含无效的缓存数据。
希望对您有所帮助。
我在使用 v15.5.6 时遇到了同样的问题。我发现解决方案是去 工具 |实时单元测试 |删除持久数据。
我确实遇到了这个问题,并且能够通过更新到 visual studio 15.7.3 并选择测试 > Live Unit Testing > 选项 - 然后 运行 [=12 来解决这个问题=].
我在一个简单的解决方案中遇到了同样的问题,其中包括一个 class 库项目和一个测试项目。显然,我的测试项目被排除在实时单元测试之外。包含项目后(右键单击项目 > Live Unit Testing > Include)图标工作正常。虽然这为我解决了问题,但我真的不清楚在我的测试 classes 中的每一行代码上都有实时测试图标的价值是什么。
我相信您已经找到了问题所在,但就我而言,帮助简单地安装 Microsoft.NET.Test.Sdk。确保将其添加到测试项目中。我花了几天时间尝试解决这个问题,就这么简单。