不能超载异步/等待与NUnit测试适配器方法

编程入门 行业动态 更新时间:2024-10-25 06:28:25
本文介绍了不能超载异步/等待与NUnit测试适配器方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我得到一个 System.Reflection.AmbiguousMatchException 在至少一个的方法是异步和当NUnit的测试使用的是 NUnit测试适配器2.0.0.0 在Visual运行的方法名称相匹配工作室。我能够没有任何问题运行测试时,我用ReSharper的单元测试转轮,当我使用的 NUnit的GUI测试运行( NUnit的-2.6.4.msi 的)。这是NUnit测试适配器中的错误?

I'm getting a System.Reflection.AmbiguousMatchException when at least one of the methods are async and the method names match when the NUnit tests are run using the NUnit Test Adapter 2.0.0.0 in Visual Studio. I'm able to run the tests without problem when I use the ReSharper unit test runner and when I use the NUnit GUI test runner (NUnit-2.6.4.msi). Is this a bug in the NUnit Test Adapter?

[TestFixture] public class SimpleRepro { [Test] [TestCase("I'm valid")] [TestCase("So am I!")] public async Task Foo(string resource) { Assert.IsNotNull(resource); await Task.Delay(new TimeSpan(0, 0, 1)); } [Test] public async Task Foo() { Assert.IsNotNull(Guid.NewGuid().ToString("N")); await Task.Delay(new TimeSpan(0, 0, 1)); } }

我已经交叉张贴这在 GitHub的问题列表。

推荐答案

这是由的库业主的。根据他们的意见看起来这将在未来的版本中得到解决:

This was confirmed as a bug by one of the library owners. According to their comment it looks like this will be addressed in a future release:

由于它只发生在适配器,它应该是我们能够解决!

Since it only occurs in the adapter, it should be something we can fix!

这当然是个好消息。在此同时,你可以解决此问题通过不超载异步/ await方法在单元测试。

This is great news of course. In the mean time you can work around this issue by not overloading async/await methods in your unit tests.

更多推荐

不能超载异步/等待与NUnit测试适配器方法

本文发布于:2023-11-03 16:31:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555588.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适配器   测试   方法   NUnit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!