I created the following structure:
├── Assets
├── Scenes
├── Scripts
│ └── MyExample.cs
├── Tests
│ ├── MyExampleTest.cs
│ └── Tests.asmdef
Now, when I click on Run All, in the Test Runner window, in Unity, I have the following error:
The type or namespace name `MyExample' could not be found. Are you missing an assembly reference?
In Visual Studio I have two projects:
Assembly-CSharp (containing src)
Tests (containing Tests)
I added Assembly-CSharp as a reference in the second project. Visual Studio is able to build the solution with no errors.
Does anyone know how to properly setup a UnitTest regression for a Unity project?
This is Tests.asmdef
{
"name": "Tests",
"optionalUnityReferences": [
"TestAssemblies"
]
}
MyExampleTest.cs
using UnityEngine;
using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;
using abc;
public class MyExampleTest{
[Test]
public void NewTestScriptSimplePasses() {
// Use the Assert class to test conditions.
}
[UnityTest]
public IEnumerator NewTestScriptWithEnumeratorPasses() {
abc.Example m;
Assert.That(false);
yield return null;
}
}
MyExample.cs
namespace abc
{
public class Example
{
}
}