我在OSX上使用Xamarin Studio,并且已经使用NUnit.Framework实现了PCL项目的测试套件(未引用View iOS和Android)。通过GUI在Xamarin Studio中的所有功能都可以正常运行(所有测试都已运行并且可以正常工作)。
现在,我正在尝试将测试套件执行集成到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源一起使用,但结果没有改变。
如果我没有在方法签名中传递此参数,但是它设置了方法test,则会运行并正常运行。
我该如何解决?
我也读过类似问题类似问题,但它不能解决,因为结果是相同的(测试未运行)。
我的环境是
=== 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句