使用招与Windows应用商店的单元测试 [英] Using Fiddler with Windows Store Unit Test

查看:146
本文介绍了使用招与Windows应用商店的单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要运行小提琴手,以帮助调试我正在开发一个可移植的API客户端。

I want to run Fiddler to help debug a portable API client that I'm developing.

在Visual Studio中,Windows应用商店单元测试项目属性页上>调试选项卡,我已经检查了允许本地网络环回选项。

In Visual Studio, on the Windows Store Unit Test project property page > Debug tab I have checked the 'Allow Local Network Loopback' option.

商店单元测试过程中运行每个Web请求失败了 System.Net.Sockets.SocketException A连接尝试失败,因为连接的方并在一段时间后没有正确答复或建立的连接失败,因为连接主机未能响应127.0.0.1:8888

Every web request run during a store unit test fails with a System.Net.Sockets.SocketException : A connection attempt failed because the connected party did not properly respond after a period of time or established connection failed because connected host has failed to respond 127.0.0.1:8888.

我连接到URI是不是本地的 - 但另一台机器的本地网络上 - 所以这小提琴手环回地址确实是从全局代理设置未来

The Uri I'm connecting to is not local - but another machine on the local network - so this fiddler loopback address is indeed coming from the global proxy setting.

我知道,<一个href="http://blogs.msdn.com/b/fiddler/archive/2011/12/10/fiddler-windows-8-apps-enable-loopback-network-isolation-exemption.aspx"相对=nofollow> Windows应用商店的应用程序,你必须启用回送网络隔离豁免,并已经选中的用户界面,上市(尽管他们没有被涉及到VS或本机测试项目)的每一个应用程序容器 - 无济于事。

I know that for Windows Store Apps you have to enable the loopback network isolation exemptions and have ticked every app container listed in the UI for that (despite none of them being related to VS or this unit test projects) - to no avail.

我也试着禁用IPv6的提琴手 - 不知道为什么,我认为可能的工作,但它是值得平底船 - 它也不能工作。

I've also tried disabling IPv6 in Fiddler - don't know why I thought that might work, but it was worth a punt - it didn't work either.

任何人有什么想法!?

推荐答案

好了 - 虽然我是在正确的轨道,心想一定是有注册的单元测试项目应用程序容器 - 我没想到的是,它可能只被激活的而MSTest的运行的。

Okay - whilst I was on the right track, thinking that there must be some app container registered for the unit test project - what I didn't think was that it might only be active while MSTest is running.

您需要调试Windows应用商店的单元测试(所有项目的测试),并坚持一个断点(暂停执行测试运行的),这样​​的话它会出现在AppContainers内的提琴手环回扩展列表工具。

You need to debug the Windows Store unit test (any of the tests in the project) and stick a breakpoint in (to halt execution of the test runner) so it will then appear in the list of AppContainers within Fiddlers' Loopback Extensions tool.

所以 - 定的这个测试:

So - given this test:

[TestMethod]
public async Task Example()
{
    var result = await GetSomeData(); //<-- breakpoint
    Assert.IsNotNull(result);
}

private async string GetSomeData()
{
    //TODO something that makes a web request with, say, HttpClient
}

你要做的就是断点上面显示的行 - 然后从提琴手推出Win8的配置选项 - 你会发现你的单元测试项目出现在AppContainers名单

All you do is breakpoint the line shown above - and then launch the 'Win8 Config' option from Fiddler - and you'll see that your unit tests project appears in the list of AppContainers.

启用环回用于该应用程序容器,保存更改,然后继续在你的单元测试 - 你应该看到交通正确捕获

Enable loopback for that app container, save the changes and then continue in your unit test - you should see the traffic correctly captured.

做这一次又好像你不必再这样做之后 - 我已经关闭了小提琴手并重新启动它和流量仍然正确捕获

After doing this once it would seem that you don't have to do it again - I've closed down fiddler and restarted it and the traffic is still captured correctly.

然而,有一个警告的话,一旦你这样做的环回豁免工具将抱怨有关豁免被定义为一个SID为其中有没有,如果它推出AppContainer - 除非你碰巧再次运行单元测试

One word of warning, however, once you do this the Loopback exemptions tool will moan about an exemption being defined for a SID for which there is no AppContainer if it is launched - unless you happen to be running a unit-test again.

这篇关于使用招与Windows应用商店的单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆