TestMethod的:异步任务TestSth()不能与.NET 4.0的工作 [英] TestMethod: async Task TestSth() does not work with .NET 4.0

查看:342
本文介绍了TestMethod的:异步任务TestSth()不能与.NET 4.0的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行在.NET 4.0异步测试方法BCL异步和MSTest的。

I'm trying to run asynchronous test methods with .NET 4.0 BCL Async and MsTest.

看来,这个设置不能够处理的 [TestMethod的]异步的任务 TestSth()的由于测试案例探险家丢失的条目。更改签名异步的无效,我可以运行测试用例,但之后用错误的结果(没有错误将在所有的报告)。

It seems that this setup is not able to deal with [TestMethod] async Task TestSth() due to a missing entry in the test case explorer. After changing the signature to async void, I can run the the test case but with the wrong outcome (no errors will be reported at all).

我已经看到在<一的attemt href=\"http://stackoverflow.com/questions/14283322/running-async-task-unit-tests-with-tfs-2010\">Running与TFS 2010 异步任务单元测试,但我认为应该有一个prettier的方式来解决这个问题。

I have seen an attemt at Running Async Task unit tests with TFS 2010 but I think there should be a prettier way to tackle the problem.

有什么建议?

推荐答案

您只能使用异步关键词与MSTest的参照的类库针对.NET 4.5。

You can only use the async keyword with an MSTest-referencing class library targeting .NET 4.5.

如果您不能使用无论出于何种原因.NET 4.5,那么你就必须忍受手动等待的任务。

If you can't use .NET 4.5 for whatever reason, then you'll just have to live with waiting on the tasks manually.

和即使的生产的code(即被测code)不能使用.NET 4.5,为什么不能测试项目这样做呢?如果你已经有了VS 2012+提供给你,那么.NET 4.5将被安装在开发机器上。

And even if the production code (i.e. the code under test) can't use .NET 4.5, why can't the test project do so? If you already have VS 2012+ available to you, then .NET 4.5 will be installed on your development machine.

这篇关于TestMethod的:异步任务TestSth()不能与.NET 4.0的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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