Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit is not running my test cases

I have a test case that looks like:

namespace UnitTests

[<TestFixture>]
module ValidatorTests = 

    [<Test>]
    let VerifyBasicFunctionality () = 
        Assert.That(bool)
        Assert.That(bool)

and when I try to run it in the Visual Stuido test explorer, nothing happens (even with the Test Adapter for NUnit 3) and just says "Successful Build" and no tests discovered. Then when I run from the commandline with the nunit-console runner (tried with v.1, v.2, v.4) I get something different:

$ nunit-console4 bin/Release/UnitTests.dll
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment - 
   OS Version: Unix 15.6.0.0
  CLR Version: 4.0.30319.42000 ( 4.4.2 (Stable 4.4.2.11/f72fe45 Thu Aug 11 06:03:25 BST 2016) )

.N.N.N
Tests run: 0, Failures: 0, Not run: 3, Time: 0.011 seconds

When I run this with the -xmlConsole flag, I get this:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="bin/Release/UnitTests.dll" total="0" failures="0" not-run="3" date="2016-09-08" time="10:26:00">
  <environment nunit-version="2.4.8.0" clr-version="4.0.30319.42000" os-version="Unix 15.6.0.0" platform="Unix" cwd="/SOMEUSER/SOMEPATH/UnitTests" machine-name="gmaini-m.jet.local" user="SOMEUSER" user-domain="SOMELOCALBOX" />
  <culture-info current-culture="en-US" current-uiculture="en-US" />
  <test-suite name="bin/Release/UnitTests.dll" success="True" time="0.010" asserts="0">
    <results>
      <test-suite name="UnitTests" success="True" time="0.008" asserts="0">
        <results>
          <test-suite name="ValidatorTests" success="True" time="0.001" asserts="0">
            <results>
              <test-case name="UnitTests.ValidatorTests.VerifyBasicFunctionality" executed="False">
                <reason>
                  <message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
                </reason>
              </test-case>
              <test-case name="UnitTests.ValidatorTests.VerifyBasicOtherFunctionality" executed="False">
                <reason>
                  <message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
                </reason>
               </test-case>
               <test-case name="UnitTests.ValidatorTests.VerifyBasicSomeFunctionality" executed="False">
                <reason>
                  <message><![CDATA[UnitTests.ValidatorTests is an abstract class]]></message>
                </reason>
              </test-case>
            </results>
          </test-suite>
        </results>
      </test-suite>
    </results>

Any idea why it seems to discover the tests, I can dot access them with -run="Namespace.Module.Function" and talk about the fixture with -fixture="Namespace" but it won't run them? Is the UnitTests.ValidatorTests.VerifyBasicFunctionality is an abstract class a hint that there is some C# interop problem?

Thanks for your time :)

like image 844
Gina Avatar asked Oct 29 '22 20:10

Gina


1 Answers

This fix was:

namespace UnitTests

[<TestFixtureAttribute>]
type ValidatorTests () =

    [<Test>]
    member __.VerifyBasicFunctionality() =
        Assert.That(bool)
        Assert.That(bool)

Basically, making this object oriented. So my hypothesis was correct.

like image 186
Gina Avatar answered Nov 15 '22 06:11

Gina