nunit-console 不 运行 使用 TestCase 和 TestCaseSource 进行测试

nunit-console not run tests with TestCase and TestCaseSource

我在 OSX 上使用 Xamarin Studio,我已经实现了 PCL 项目的测试套件(没有引用 View iOS 和 Android) NUnit.Framework。通过 GUI 在 Xamarin Studio 中一切正常(所有测试都 运行ned 并且有效)。

现在我正在尝试在 Jenkins 中集成测试套件执行。当我通过命令行 运行 我的测试套件时(这发生在 Jenkins 和我的本地环境中)

 mono /Library/Frameworks/Mono.framework/Versions/3.12.0/lib/mono/4.5/nunit-console.exe Libs/Debug/MyTests.dll

我有这个输出

NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment - 
   OS Version: Unix 14.1.0.0
  CLR Version: 4.0.30319.17020 ( 3.12.0 ((detached/de2f33f Mon Feb  2 14:42:07 EST 2015) )

Tests run: 7, Failures: 0, Not run: 19, Time: 16.530 seconds

有19个测试不是运行这种动机:

<test-suite name="MyTestClass" success="True" time="0.000" asserts="0">
   <results>
      <test-case name="NamespaceExample.MyTestClass.MyTestMethod" description="My Test Description" executed="False">
         <reason>
            <message><![CDATA[Method MyTestMethod's signature is not correct: it must not have parameters.]]></message>
         </reason>
      </test-case>
   </results>
</test-suite>

这类测试都有一个共同的特点,就是使用TestCase。例子

namespace NamespaceExample
{
    [TestFixture]
    public class MyTestClass
    {

        public IMyService service;

        [SetUp]
        public void TestCase()
        {
            // this method will be called before running every test
            service = new MyService ();
        }

        [Test (Description = "My Test Description")]
        [TestCase("it")]
        public void MyTestMethod(string code)
        {
            string terms = service.MethodToTest (code);
            Assert.IsNotNull (terms);
        }
    }
}

似乎 nunit-console 没有 运行 使用 TestCase 参数进行测试。我还尝试将 TestCaseSource 与 IEnumerable 源一起使用,但结果没有改变。

如果我不在方法签名中传递此参数,但它在方法测试中设置 运行ned 并且工作正常。

我该如何解决?

我也读过这类问题 Similar Question 但它没有解决,因为结果是一样的(测试未 运行ned)。

我的环境是

=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: xxx
Runtime:
    Mono 3.12.0 ((detached/de2f33f)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 312000076

=== Apple Developer Tools ===

Xcode 6.0 (6299)
Build 6A313

=== Xamarin.iOS ===

Version: 8.6.1.20 (Indie Edition)
Hash: xxx
Branch: 
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Indie Edition)
Android SDK: xxx/android-sdk-mac_x86
    Supported Android versions:
        1.6    (API level 4)
        2.1    (API level 7)
        2.2    (API level 8)
        2.3    (API level 10)
        3.1    (API level 12)
        4.0    (API level 14)
        4.0.3  (API level 15)
        4.1    (API level 16)
        4.2    (API level 17)
        4.3    (API level 18)
        4.4    (API level 19)
        4.4.87 (API level 20)
        5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 507010017
Git revision: xxx
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

=== Operating System ===

Mac OS X 10.10.2
Darwin LS.local 14.1.0 Darwin Kernel Version 14.1.0
    Mon Dec 22 23:10:38 PST 2014

尝试使用更新的 NUnit 版本。您正在使用 NUnit 2.4.8。 Xamarin Studio 的内置 NUnit 运行程序使用 NUnit 2.6.3 版。

NUnit 2.5 似乎引入了对 TestCase 属性的支持。您可以从以下网址下载 NUnit:http://nunit.org/index.php?p=download