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>
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118
  • 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. – Mark Seemann May 29 '16 at 11:47
  • Thanks Mark. However, I use XUnit with FsCheck (i.e. Property tests). – Scott Nimrod May 29 '16 at 11:52
  • Yes, I can see that, but `FsCheck.XUnit` is a Glue Library for xUnit.net. It's not going to work with NUnit. – Mark Seemann May 29 '16 at 11:53
  • 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#? – Scott Nimrod May 29 '16 at 11:54
  • 2
    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... – Mark Seemann May 29 '16 at 11:58
  • 5
    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. – Mark Seemann May 29 '16 at 12:01
  • 1
    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. – Scott Nimrod May 29 '16 at 12:12
  • 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. – Guy Coder May 29 '16 at 12:50
  • 2
    Of interest: [Why can't the NUnit Test Adapter find my FsUnit tests?](http://stackoverflow.com/q/37297238/1243762) – Guy Coder May 29 '16 at 12:51
  • 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. – Guy Coder May 29 '16 at 13:14
  • 2
    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. – TheInnerLight May 29 '16 at 22:28
  • 1
    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. – TheInnerLight May 29 '16 at 22:33
  • @ScottNimrod - How did you create this project? By hand, or did you use the Project Scaffold? (https://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 (http://fsprojects.github.io/Paket/) a try. – rmunn May 30 '16 at 09:59
  • The NUnit3TestAdapter worked for me. Thanks. =) – Scott Nimrod Jul 14 '16 at 11:51
  • I keep revisiting this issue and am no longer able to get my test discovery to work... – Scott Nimrod Jul 06 '17 at 20:14

1 Answers1

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.

marklam
  • 5,346
  • 1
  • 24
  • 26
  • (Just noticed that this suggestion is covered in the question that Guy Coder linked to in the comments above. +1 to that.) – marklam Jun 08 '16 at 14:10