Good morning everybody. I discovered tests in Unity and I am pretty excited to put these into action. However, I cannot seem to get the tests to recognize the classes I have built, even though the appear to be fine elsewhere in the project.
Radians.cs
using System;
namespace Trig // I tried with and without the namespace, neither worked.
{
public static class Radians
/* To Be Tested */
{
public static double ToDegrees(double d)
/* To Be Tested */
{
Radian radians = new Radian(d);
return radians.ToDegrees();
}
public static double FromDegrees(double d)
/* To Be Tested */
{
return d * Math.PI / 180.0;
}
public static double Coefficient(double d)
/* To Be Tested */
{
return d/Math.PI;
}
}
}
Radians.spec.cs
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using Trig;
public class RadiansTest
{
// A Test behaves as an ordinary method
[Test]
public void RadiansSimplePasses()
{
// Use the Assert class to test conditions
double coefficient = Radians.Coefficient(0.5); // Access the static field correctly
Assert.AreEqual(180.0 / System.Math.PI, coefficient);
}
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
// `yield return null;` to skip a frame.
[UnityTest]
public IEnumerator RadiansWithEnumeratorPasses()
{
// Use the Assert class to test conditions.
// Use yield to skip a frame.
yield return null;
}
}