当至少一个方法异步并且方法名称与使用System.Reflection.AmbiguousMatchException ="www.nuget/packages/NUnitTestAdapter/" rel ="nofollow">在Visual Studio中为NUnit测试适配器2.0.0.0 .使用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问题列表上.
I've cross posted this on the GitHub issues list.
推荐答案图书馆所有者.根据他们的评论,这似乎将在将来的版本中解决:
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!
这当然是个好消息.同时,您可以通过在单元测试中不重载异步/等待方法来解决此问题.
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测试适配器不能重载异步/等待方法
发布评论