I want to write xUnit
tests for my Unity project.
While I am fairly new to Unity itself, I have experience with xUnit
, hence this test framework and not another one.
Now I created a new solution in Visual Studio 2019 and created a xUnit
project.
The test solution is in a folder structure next to my Unity project, like proposed in this thread: Unit tests are inconclusive when adding xUnit project to Unity project.
I also added the (temporary) Unity project csproj
file (it seems to be created new whenever Unity builds the project new).
Now when I want to run a xUnit
test, I get error whenever I run "Unity specific code", such as UnityEngine.Debug.Log
or UnityEngine.JsonUtility.FromJson
.
The error message reads the following for example
Message:
System.Security.SecurityException : ECall methods must be packaged into a system module.
Stack Trace:
DebugLogHandler.LogFormat(LogType logType, Object context, String format, Object[] args)
Logger.Log(LogType logType, Object message)
Debug.Log(Object message)
Settings.get_AppSettings() line 25
SettingsTest.AppSettings_Default_Test() line 25
What can I do in order to run my xUnit
tests in Visual Studio?