Luigi Saggese
Luigi Saggese

Reputation: 5379

nunit-console not run tests with TestCase and TestCaseSource

I'm using Xamarin Studio on OSX and i have implemented a test suite of PCL project (without references to View iOS and Android) with NUnit.Framework. All works fine inside Xamarin Studio via GUI (all tests are runned and it worked).

Now i'm trying to integrate test suite execution inside Jenkins. When i run via command line my test suite (this happens on Jenkins and also on my local environment)

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

i have this output

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

There are 19 tests not running with this kind of motivation:

<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>

this kind of tests have all a common feature, use of TestCase. Example

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);
        }
    }
}

Seems that nunit-console not run test with TestCase parameters. I have also tried to use TestCaseSource with an IEnumerable source but results doesn't change.

If i don't pass this parameter inside method signature, but it sets inside method test is runned and works fine.

How could i solve?

I have read also this kind of issue Similar Question but it doesn't solve, because result it's same (tests not runned).

My environment is

=== 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

Upvotes: 0

Views: 1420

Answers (1)

Matt Ward
Matt Ward

Reputation: 47987

Try using a more recent NUnit version. You are using NUnit 2.4.8. Xamarin Studio's built in NUnit runner uses version 2.6.3 of NUnit.

It looks like NUnit 2.5 introduced support for the TestCase attribute. You can download NUnit from: http://nunit.org/index.php?p=download

Upvotes: 1

Related Questions