我有一个用F#编写的单元测试,它使用Unquote库来执行这样的断言:
module Iccm
open System
open NUnit.Framework
open Swensen.Unquote
[<TestCase("0000000000000000000000000546314", "http://...er.aspx?FolderID=0000000000000000000000000546314")>]
[<TestCase("0000000000000000000000000535126", "http://...er.aspx?FolderID=0000000000000000000000000535126")>]
[<TestCase("0000000000000000000000000545845", "http://...er.aspx?FolderID=0000000000000000000000000545845")>]
[<TestCase("0000000000000000000000000364684", "http://...er.aspx?FolderID=0000000000000000000000000364684")>]
let ``callLink returns complete Uri with given eFolderId embedded``
eFolderId expectedUri =
test <@ Iccm.callLink eFolderId = expectedUri @>
到目前为止非常好。我让测试失败,所以我可以看到Unquote如何逐步显示引用表达式的评估,但我没有在我的测试运行器控制台中获得非引用报告
C:\TFS\SANDBOX_2456764.0\PrototypeWorkspace\IccmToTfs\src\IccmToTfs.Console.Tests\bin\Debug>"C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console-x86.exe" IccmToTfs.
Console.Tests.dll
NUnit-Console version 2.6.4.14350
Copyright (C) 2002-2012 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: Microsoft Windows NT 6.1.7601 Service Pack 1
CLR Version: 2.0.50727.5485 ( Net 3.5 )
ProcessModel: Default DomainUsage: Single
Execution Runtime: net-3.5
.F.F.F.F.......
Tests run: 11, Errors: 4, Failures: 0, Inconclusive: 0, Time: 0.319073211837137 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
Errors and Failures:
1) Test Error : Iccm.callLink returns complete Uri with given eFolderId embedded("0000000000000000000000000545845","http://usas25/esdSSO/eExternalForm.asp?service=IC
CM%20e-Service%20Desk&redirect=http://usas25/esd/eFolder.aspx?FolderID=0000000000000000000000000545845%2526client=external%2526Service=ICCM+e-Service+Desk")
System.ArgumentException : Object of type 'System.String' cannot be converted to type 'System.Uri'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
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)
2) Test Error : Iccm.callLink returns complete Uri with given eFolderId embedded("0000000000000000000000000546314","http://usas25/esdSSO/eExternalForm.asp?service=IC
CM%20e-Service%20Desk&redirect=http://usas25/esd/eFolder.aspx?FolderID=0000000000000000000000000546314%2526client=external%2526Service=ICCM+e-Service+Desk")
System.ArgumentException : Object of type 'System.String' cannot be converted to type 'System.Uri'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
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)
我在命令行上尝试了NUnit,在Visual Studio 2013中尝试了ReSharper,似乎都没有人知道如何读取Unquote输出。有谁知道为什么?是否有一个不同的测试运行器,我必须使用Unquote才能正常工作?
更新
这个其他测试用例失败并且非常好地演示了Unquote输出:
[<TestCase(3s, "03/02/2015", 3150202)>]
let ``callPriority returns expected integer given a priority and date``
priority dateString expectedInteger =
let date = DateTime.Parse(dateString)
test <@ Iccm.callPriority priority date = expectedInteger @>
Unquote的输出:
Iccm.callPriority 3s 3/2/2015 12:00:00 AM = 3150202
3150302 = 3150202
false