I have a static C# class that I want to test but I’m having trouble accessing the class in my test files.
I’m getting the error: The name ‘SampleClass’ does not exist in the current context [Tests]csharp(CS0103)
Here is what I have done so far.
- Create “EditMode”
Tests.asmdef
file inTests
directory - Create
GameAssembly
Assembly Definition in myScripts
directory - Add the
GameAssembly
to Assembly Definition References list in Tests.asmdef.
Is there something I’m missing?
My test file:
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
public class SampleClassTest
{
// A Test behaves as an ordinary method
[Test]
public void AddTest()
{
int result = SampleClass.Add(1, 1);
Assert.AreEqual(2, result);
}
}
Tests Assembly config:
GameAssembly config: