title: F# unit test projects in linux with mono (FAKE, NUnit 3)
body: <p>I am trying to set up a very simple test F# project in linux with mono, using <a href="https://github.com/fsprojects/Forge" rel="nofollow">Forge</a> to set up the project and install nuget packages. Forge creates a <code>build.fsx</code> file which uses FAKE. I've tried to adjust this build file <em>(in order to add tests)</em> with inspiration from this tutorial <a href="http://fsharp.github.io/FAKE/gettingstarted.html" rel="nofollow">http://fsharp.github.io/FAKE/gettingstarted.html</a>. The tutorial, however, is using C# for testing and assumes Windows with .Net as environment. I want to use F# for testing and linux with mono as environment.</p>
  
  <p>I think I almost got it working, but I am getting some cryptic error messages from NUnit. When running the <code>build.fsx</code> file I get following errors at the end:</p>
  
  <pre><code>...
  Invalid argument: -nologo
  The value '/home/michel/Documents/FSHARP/UnitTests/test/NUnit.Test.MyTests.dll' is not valid for option '--labels'.
  Invalid argument: -xml:./test/TestResults.xml
  Running build failed.
  Error:
  NUnit test failed (255).
  
  ---------------------------------------------------------------------
  Build Time Report
  ---------------------------------------------------------------------
  Target      Duration
  ------      --------
  Clean       00:00:00.0036366
  Build       00:00:00.0402828
  BuildTest   00:00:00.4911710
  Total:      00:00:00.7494956
  Status:     Failure
  ---------------------------------------------------------------------
    1) Fake.UnitTestCommon+FailedTestsException: NUnit test failed (255).
    at Fake.NUnitSequential.NUnit (Microsoft.FSharp.Core.FSharpFunc`2 setParams, IEnumerable`1 assemblies) &lt;0x41d27e50 + 0x0039f&gt; in &lt;filename unknown&gt;:0 
    at FSI_0001+clo@32-4.Invoke (Microsoft.FSharp.Core.Unit _arg4) &lt;0x41d27dc0 + 0x0006f&gt; in &lt;filename unknown&gt;:0 
    at Fake.TargetHelper+targetFromTemplate@195[a].Invoke (Microsoft.FSharp.Core.Unit unitVar0) &lt;0x41cd59b0 + 0x00023&gt; in &lt;filename unknown&gt;:0 
    at Fake.TargetHelper.runSingleTarget (Fake.TargetTemplate`1 target) &lt;0x41ccb490 + 0x000ca&gt; in &lt;filename unknown&gt;:0
  </code></pre>
  
  <p>My <code>build.fsx</code> file looks like this</p>
  
  <pre><code>// include Fake libs
  #r "./packages/FAKE/tools/FakeLib.dll"
  
  open Fake
  
  
  // Directories
  let buildDir  = "./build/"
  let testDir = "./test/"
  
  // version info
  let version = "0.1"  // or retrieve from CI server
  
  // Targets
  Target "Clean" (fun _ -&gt;
      CleanDirs [buildDir; testDir]
  )
  
  Target "Build" (fun _ -&gt;
      //MSBuildDebug buildDir "Build" appReferences
      !! "/UnitTesting/*.fsproj"
      |&gt; MSBuildRelease buildDir "Build"
      |&gt; Log "AppBuild-Output: "
  )
  
  Target "BuildTest" (fun _ -&gt;
                      !! "src/NUnit.Test.MyTests/*.fsproj"
                      |&gt; MSBuildDebug testDir "Build"
                      |&gt; Log "TestBuild-Output: "
  )
  
  Target "Test" (fun _ -&gt;
                 !! (testDir + "/NUnit.Test.MyTests.dll")
                 |&gt; NUnit (fun p -&gt;
                           { p with
                                 ToolPath = "packages/NUnit.ConsoleRunner/tools"
                                 //DisableShadowCopy = true;
                                 OutputFile = testDir + "TestResults.xml" })
  )
  
  Target "Default" (fun _ -&gt; trace "HEEEELLOOOOOO world from FAKE!!!")
  
  "Clean" ==&gt; "Build" ==&gt; "BuildTest" ==&gt; "Test" ==&gt; "Default"
  
  RunTargetOrDefault "Default"
  </code></pre>
  
  <p>FAKE seems to be looking for a file <code>nunit-console.exe</code> under the <code>packages/NUnit.ConsoleRunner/tools</code> directory, but there is no such file. However, there is a <code>nunit3-console.exe</code> file, so I just made a copy of this file with the name <code>nunit-console.exe</code>.</p>
  
  <p>My simple test file <code>NUnit.Test.MyTests.fs</code> looks like following:</p>
  
  <pre><code>namespace NUnit.Test.MyTests
  
  module testmodule =
  
      open NUnit.Framework
  
      let SayHello name = "Hello"
  
      [&lt;TestFixture&gt;]
      type myFixture() =
  
          [&lt;Test&gt;]
          member self.myTest() =
              Assert.AreEqual("Hello World!", SayHello "World")
  </code></pre>
  
  <p>and the file <code>test/NUnit.Test.MyTests.dll</code> seems to be generated just fine.</p>
  
  <p><strong>What does the cryptic error message mean, and how can I fix it so I can run my tests?</strong></p>