我试图运行在.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).
我已经看到在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的工作
发布评论