单元测试未出现

jya*_*nks 7 unit-testing visual-studio-2012 windows-store-apps

我在Windows 8 Release Preview上使用Visual Studio Express 2012,我似乎无法让我的单元测试出现在测试资源管理器中.

我有一个名为TestApp.Entity的类,以及TestApp.EntityTest ...

这是我的代码:

namespace TestApp.Entity.Test
{
    using System;
    using System.Net.Http;
    using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
    using TestApp.Domain;

    [TestClass]
    public class EntityTests
    {
        [TestMethod]
        public async void TestObject1Deserialize()
        {
            Uri agencyUri = new Uri("*removed*");
            HttpClient httpClient = new HttpClient();
            HttpResponseMessage response = await httpClient.GetAsync(agencyUri);

            string responseBodyAsText = await response.Content.ReadAsStringAsync();
            List<Agency> agencyList = Deserializers.AgencyDeserialize(responseBodyAsText);

            CollectionAssert.Contains(agencyList, new Agency() { Tag = "*removed*", Title = "*removed*", ShortTitle = "", RegionTitle = "*removed*" });
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

我认为这就是我需要做的全部,但它们仍未出现在测试资源管理器中.任何意见将是有益的.

jya*_*nks 5

根据Stephen Cleary的说法,"你需要进行单元测试,async Task而不是async void让他们正常工作".

这解决了问题并且出现了测试.奇怪的是,当我使用void时没有出现错误,但现在我知道了.谢谢!