Why am I not able to use the latest version of NUnit and FsCheck with F#?
Asked Answered
A

1

6

I would like to use the latest versions of NUnit, FsCheck, and F#. However, when I point to the latest versions of my packages, my unit tests do not get discovered.

However, my property-based tests are discovered (i.e. FsCheck).

My packages are the following:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="FsCheck" version="2.4.0" targetFramework="net461" />
  <package id="FsCheck.Xunit" version="2.4.0" targetFramework="net461" />
  <package id="FSharp.Core" version="4.0.0.1" targetFramework="net461" />
  <package id="FsUnit" version="2.2.0" targetFramework="net461" />
  <package id="NUnit" version="3.2.1" targetFramework="net461" />
  <package id="xunit.abstractions" version="2.0.0" targetFramework="net461" />
  <package id="xunit.extensibility.core" version="2.1.0" targetFramework="net461" />
  <package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net461" />
  <package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net461" />
</packages>

My app.config is the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.4.0" sku=".NETFramework,Version=v4.6.1" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-9999.9999.9999.9999" newVersion="3.2.1" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
Annabell answered 29/5, 2016 at 11:28 Comment(15)
Your packages contain both NUnit and xUnit.net. If you want to use NUnit, you should probably start by removing all the xUnit.net packages.Dual
Thanks Mark. However, I use XUnit with FsCheck (i.e. Property tests).Annabell
Yes, I can see that, but FsCheck.XUnit is a Glue Library for xUnit.net. It's not going to work with NUnit.Dual
By the way, I'm currently reading your blog on Haskell's default support for Port and Adapter architecture. Do you think I am ready to pickup Haskell at my current level of F#?Annabell
I don't know. Sorry to be blunt, but you still seem to be struggling with basic F# problems, but it may be that your knowledge of C# and .NET is in your way. Perhaps Haskell will give you an opportunity for a fresh start. Maybe it'll work out better for you, but personally, I still find learning Haskell hard. Then again, I don't think I picked the easiest approach to it either...Dual
To the anonymous downvoter who seems to downvote all of Scott's questions: if you feel that his questions are bad, then tell him why you think so. Downvoting without further feedback makes it hard for him to improve.Dual
I appreciate your honesty. Honestly, I'm still searching for an exercise and/or project where these concepts begin to click for me. Until then, I guess I'll just keep practicing the basics on my off hours.Annabell
What are you using to run the test? I use VS Test explorer. I too am still unable to run NUnit 3.x, FsCheck with property test and use VS Test explorer with VS 2015 community. I am pretty sure my problem is the adapter that allows the test to run with VS Test explorer needs to be updated; thus being on the bleeding edge is as they say: bleeding. AFAIK all of those have the source code available, so if you want, dig in, update the code, and give back to the community.Benner
Of interest: Why can't the NUnit Test Adapter find my FsUnit tests?Benner
What is it that you are not getting with F#? Are you consistently getting compile errors, invalid results, or something else? If you and I are on at the same time this would be better in a chat room.Benner
I don't think Haskell is necessarily any more difficult than F#, just different. The good thing about it is that you wouldn't have an OO crutch to fall back on, the bad thing is that it'd introduce a lot of new concepts quite quickly. I'd say if you're interested though, go for it. I'm very far from a Haskell expert but I think it's a fantastic language, not least as a source of ideas for F# development.Olsen
As for the question at hand, does the FSharp.Core version of the project you are trying to test match the 4.0.0.1 found in that packages.config file? It's very easy to run into trouble by creating a new F# 4 project and then trying to test it with FsCheck, etc if you don't make sure FSharp.Core binding redirects are set up correctly.Olsen
@ScottNimrod - How did you create this project? By hand, or did you use the Project Scaffold? (github.com/fsprojects/ProjectScaffold). I found that I had lots of problems with NuGet until I started using the Project Scaffold to set up my project; it installs Paket instead, which makes sure the right binding redirects are set up. If you're still using NuGet, I'd suggest giving Paket (fsprojects.github.io/Paket) a try.Aliquant
The NUnit3TestAdapter worked for me. Thanks. =)Annabell
I keep revisiting this issue and am no longer able to get my test discovery to work...Annabell
F
1

Have you tried installing the NUnit3 test adapter so that Visual Studio knows about NUnit? https://www.nuget.org/packages/NUnit3TestAdapter

It could be that your FsCheck tests are found because Visual Studio already knows about XUnit.

Farewell answered 8/6, 2016 at 14:4 Comment(1)
(Just noticed that this suggestion is covered in the question that Guy Coder linked to in the comments above. +1 to that.)Farewell

© 2022 - 2024 — McMap. All rights reserved.