【发布时间】:2016-02-24 10:24:25
【问题描述】:
在我的单元测试项目中,我安装了 AutoFixture (v3.40.0)、NUnit (v2.6.4.) 和 AutoFixtrue.NUnit2(v3.39.0)。
我在其中一个虚拟测试用例上使用 AutoData 属性
[Test, AutoData]
public void IntroductoryTest(
int expectedNumber)
{
}
,但是在运行测试时我得到了
System.Reflection.TargetParameterCountException : Parameter count mismatch.
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at NUnit.Core.Reflect.InvokeMethod(MethodInfo method, Object fixture, Object[] args)
at NUnit.Core.TestMethod.RunTestMethod()
at NUnit.Core.TestMethod.RunTestCase(TestResult testResult)
有什么我没有安装或缺少的东西吗?
【问题讨论】:
-
你需要 both NUnit 和 NUnit2 吗?这可能会导致该问题。
-
FWIW,NUnit 2 的插件模型导致各种问题,所以如果你有任何选择,请考虑使用 xUnit.net,其中 AutoFixture.XUnit2 i> 和 AutoFixture.Xunit 多年来一直完美无缺。
标签: c# unit-testing nunit autofixture