Reputation: 7908
I'm test-driving the .Net ecosystem via Mono, but I've run into a problem with NUnit. I have the following example test file:
using NUnit.Framework;
namespace Tests
{
[TestFixture]
class Tests
{
[Test]
public void FailingTest()
{
Assert.Fail("A message");
}
[Test]
public void PassingTest()
{
}
}
}
Which I'm building and running via:
cweber@mbp ~/temp/monoexample$ dmcs tests.cs -target:library -r:$NUNIT_FRAMEWORK_DLL
cweber@mbp ~/temp/monoexample$ ls tests.dll
tests.dll
cweber@mbp ~/temp/monoexample$ nunit-console tests.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 14.5.0.0
CLR Version: 4.0.30319.17020 ( 4.2.1 (explicit/6dd2d0d Fri Nov 6 12:25:19 EST 2015) )
.N.N
Tests run: 0, Failures: 0, Not run: 2, Time: 0.014 seconds
As you can see, neither of the tests are running.
I've Googled everything I can think of, and I've done all of the experimenting I can think of (e.g., removing the namespace, messing with fixture
and run
flags, etc). I've clearly simplified this example as much as I know how, but I've run out of ideas. Please let me know if I can provide any more information!
I'm sorry to ask this question if the answer ends up being obvious.
Upvotes: 1
Views: 875
Reputation: 74124
Look in your TestResult.xml
file and you will see the reason way, class is not public ;-)
<results>
<test-case name="Tests.Tests.FailingTest" executed="False">
<reason>
<message><![CDATA[Fixture class is not public]]></message>
</reason>
</test-case>
<test-case name="Tests.Tests.PassingTest" executed="False">
<reason>
<message><![CDATA[Fixture class is not public]]></message>
</reason>
</test-case>
</results>
Upvotes: 4