2

I've been searching a lot about running unit tests via cli in macos and i find a path to achieve this but i cant't run them all.

I'm using Unity3D engine to create the solution and csproj and i need to find a way to run the tests via console. So what i did?

Running in macos i have installed mono, msbuild and nunit-console and create a simple unity project just doing some basic assert

[Test]
    public void Should_Pass()
    {
        Assert.IsTrue(true);
    }

So i build the solution using

msbuild path/to_mysolution.sln

Everything is fine by now. Then i run the tests with nunit-console pointing to the .dll

nunit-console path/to_mydll.dll

And this works!

The problem seems to be when i'm using some unity functionality i received

System.MissingMethodException : Attempted to access a missing method

My objective is running the tests without opening Unity.

I've been trying to build and tests with dotnet but cannot figure why i having these error

/usr/local/share/dotnet/sdk/2.1.4/Microsoft.Common.CurrentVersion.targets(1124,5): error MSB3644: 

The reference assemblies for framework ".NETFramework,Version=v4.5" were not found.

  • You have to tell us which versions of the various NUnit components you are using. :-) – Charlie Feb 24 '18 at 01:42
  • @Charlie if i use the mono built-in nunit it throws me that error and if i use the nunit3 it throws me this `The NUnit 3 driver encountered an error while executing reflected code.` The problem is when i use Unity stuff like Debug.Log from UnityEngine library (i'm trying to figure it out what the real issue is, i think is the reflection part) – Martin Gonzalez Feb 24 '18 at 03:15
  • "mono built-in" makes me guess. I'm guessing NUnit 2.4.8, but it depends on your mono. Pick a number. :-) Also, there are two things to tell us here: version of the nunit framework you are referencing in your tests and version of the console runner (if that's what you are using). Both are easy to find in your logs. Bear in mind that NUnit 2 and 3 are pretty much like two different products - they don't mix. – Charlie Feb 25 '18 at 01:37
  • I found the problem. I'm running unit test that uses unity native code so thats why those methods are missing. NUnit works with pure .net. – Martin Gonzalez Feb 26 '18 at 01:59

0 Answers0