2016-10-18 23 views
2

運行FsCheck你好我試圖用xunit.runner.console運行FsCheck.Xunit測試,並收到以下異常:如何使用的xUnit

Kata.TennisProperties.Given advantaged player when advantaged player wins score is correct [FAIL] 
    System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. 
    ---- System.Exception : The type Kata.Tennis+Player is not handled automatically by FsCheck. Consider using another type or writing and registering a generator for it. 
    Stack Trace: 
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 
     at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 

我試圖按照Mark Seemann's talk。我的設置如下:

我有一個單一的庫類型項目whith兩個文件。一個代碼需要測試,另一個代碼需要測試代碼。該項目編譯得很好。我沒有使用VS IDE,而是使用帶有用於F#的Ionide插件的VSCode文本編輯器。

我試過了各種設置,有和沒有FSharp.Core nuget安裝,有和沒有版本規範FSharp.Core

任何想法在哪裏看得更遠?我正在用盡想法並且感到沮喪。我已經花了兩天時間了。 :)

回答

4

通過添加app.config文件波紋管修復此問題。

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
     <Paket>True</Paket> 
     <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" /> 
    </dependentAssembly> 
    </assemblyBinding> 
</runtime> 
</configuration> 

我這樣做之前,但使用VSCode + Ionide沒有配置文件添加到項目。所以,非常重要的是,不要忘記將app.config文件也添加到項目中。僅在項目文件夾中創建文件是不夠的。

+0

你有回購的地方可查看嗎? –

+0

我一直在關注這篇文章[網球卡塔](http://blog.ploeh.dk/2016/02/10/types-properties-software-designing-with-types/)。我已經按照你的要求升級了。這裏是鏈接:https://github.com/adicirstei/tennis-kata-tut – Adrian