【问题标题】:C# UWP Visual Studio 2017 Unit TestsC# UWP Visual Studio 2017 单元测试
【发布时间】:2018-03-19 10:04:40
【问题描述】:

我正在使用 Visual Studio 2017 版本 15.6.1 为我的应用创建单元测试。

我添加了一个新项目,单元测试项目(通用 Windows)。
项目目标版本是 Fall Creators Update (10.0; Build 16299)
最低版本为 11 月更新(10.0;内部版本 10586)

我已将 UnitTest1.cs 编辑如下:

[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {
        Assert.AreEqual(0, 0);
    }

    [TestMethod]
    public void TestMethod2()
    {
        Assert.AreEqual(0, 0);
    }
}

在左侧的测试资源管理器中,我看到了两个测试。我点击全部运行。

只有一个窗口弹出,在输出中有这样的信息:

[3/13/2018 4:13:24 PM Informational] ------ Load Playlist started ------
[3/13/2018 4:13:24 PM Informational] ========== Load Playlist finished (0:00:00.0155005) ==========
[3/13/2018 4:15:01 PM Informational] ------ Run test started ------
[3/13/2018 4:16:10 PM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Failed to initialize client proxy: could not connect to test process.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
[3/13/2018 4:16:10 PM Informational] ========== Run test finished: 0 run (0:01:09.0679372) ==========
[3/13/2018 4:39:20 PM Informational] ------ Run test started ------
[3/13/2018 4:40:43 PM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Failed to initialize client proxy: could not connect to test process.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
[3/13/2018 4:40:45 PM Informational] ========== Run test finished: 0 run (0:01:25.1648961) ==========

我在这里做错了什么?

项目链接:https://ufile.io/8vifz

【问题讨论】:

    标签: c# unit-testing uwp visual-studio-2017


    【解决方案1】:

    here 提供了一个线程,提供了解决此问题的方法:

    您可以尝试在提升的命令提示符下运行CheckNetIsolation.exe LoopbackExempt -c

    它对我有用。

    【讨论】:

    • 就是这样,这就是解决此问题的解决方案。谢谢。
    猜你喜欢
    • 2017-08-13
    • 1970-01-01
    • 2015-06-16
    • 2017-08-09
    • 2019-01-19
    • 1970-01-01
    • 2017-08-13
    • 1970-01-01
    • 2018-08-18
    相关资源
    最近更新 更多