簡體   English   中英

如何使用Xunit運行FsCheck

[英]How to run FsCheck with Xunit

嗨,我正在嘗試使用xunit.runner.console運行FsCheck.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)

想聽馬克·西曼的講話 我的設置如下:

我有一個帶兩個文件的庫類型項目。 一種帶有要測試的代碼,另一種帶有測試代碼。 該項目編譯就好了。 我不是使用VS IDE,而是使用帶有Ionide F#插件的VSCode文本編輯器。

我曾嘗試與有和沒有各種設置FSharp.Core的NuGet安裝,使用和不使用的版本規范FSharp.Core

任何想法在哪里進一步看? 我的想法耗盡了,感到沮喪。 我已經花了兩天了。 :)

通過添加以下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文件也添加到項目中。 僅在項目文件夾中創建文件是不夠的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM