I tried to set up a project using Mono, C#, and NUnit.
I tried to get tests running, so I build a MSBuild/xbuild Test.csproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<OutputPath>bin</OutputPath>
<AssemblyName>Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit\lib\net45\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Test.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\mainproj.csproj">
<Name>Mainproj</Name>
</ProjectReference>
</ItemGroup>
</Project>
I built this project using xbuild Test.csproj.
The file Test.cs does contain two simple tests:
using NUnit.Framework;
namespace Foo.Test {
[TestFixture]
public class TestClass
{
[TestCase]
public void AddTest()
{
Assert.AreEqual(30, 15 + 15);
}
[TestCase]
public void Minus()
{
Assert.AreEqual(30, 15 - 15);
}
}
}
What works?
- The Test.dll is compiled successfully
What does not work
nunit-console4 bin/nunit.framework.dll bin/Test.dll does not find any tests:
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.0.0.0 CLR Version: 4.0.30319.17020 ( 4.2.1 (Stable 4.2.1.102/6dd2d0d Wed Dec 2 14:02:18 PST 2015) ) Tests run: 0, Failures: 0, Not run: 0, Time: 0.055 seconds