简体   繁体   中英

How to run FsCheck with Xunit

Hi I am trying to run FsCheck.Xunit tests with xunit.runner.console and getting the following exception:

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)

I am trying to follow Mark Seemann's talk . My setup is as follows:

I have a single library type project whith two files. One with the code to be tested and one with the test code. The project compile just fine. I am not using the VS IDE but just VSCode text editor with Ionide plugin for F#.

I have tried with various setups with and without FSharp.Core nuget installs, with and without version specification of FSharp.Core .

Any idea where to look further? I am running out of ideas and getting frustrated. I've already spent two days on this. :)

Fixed this by adding the app.config file bellow.

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

I did this before but using VSCode + Ionide didn't got the config file added to the project. So, very important, don't forget to add the app.config file to the project also. It is not enough to just create the file in project folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM