I have Max OS X 10.11.1 installed, with Xamarin on it. I wrote simple testing class, just to test running Nunit tests on Mac OS X & Ubuntu, class has literally one method which returns string:
using System;
namespace testing_project
{
public class EmptyClass
{
public EmptyClass ()
{
}
static void Main(string[] args)
{
}
public string helloWorld()
{
return "Hello World!";
}
}
}
And I have a NUnit class to test my EmptyClass:
using System;
using NUnit.Framework;
namespace testing_project
{
[TestFixture]
public class EmptyClassTest
{
[Test]
public void testHelloWorld()
{
EmptyClass empty = new EmptyClass();
Assert.AreEqual ("Hello World!", empty.helloWorld ());
}
}
}
When I run this in Xamarin studio, test is passing just fine.
How can I achieve this on CLI?
Mono includes an install of NUnit's runner/console (version 2.4.8) that is called via a shell script called
nunit-console
:So to run your tests from the CLI you can either call the NUnit's test
.csproj
or the CIL/Assembly:or
NOTE: NUnit console 2.4.x is broken due a hard-coded Windows-style Directory Separator when parsing .csproj files and creating the expected CIL/assembly location, use
MONO_IOMAP
to work around it. This is not a issue in NUnit runner 3.0.Example:
nunit-console --help