using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
public class TestScript
{
// 执行单元测试方法前被Unity自动调用
[SetUp]
public void TestScriptSetUpPasses()
{
Debug.Log("TestScriptSetUpPasses()");
}
// 测试普通方法
[Test]
public void TestScriptSimplePasses()
{
Debug.Log("TestScriptSimplePasses()");
//使用Debug.Assert()来测试条件
}
// 测试协程方法
[UnityTest]
public IEnumerator TestScriptWithEnumeratorPasses()
{
Debug.Log("TestScriptWithEnumeratorPasses()");
//使用Debug.Assert()来测试条件
//使用yield跳过一帧
yield return null;
}
// 执行完单元测试方法后被Unity自动调用
[TearDown]
public void TearDownPasses()
{
Debug.Log("TearDownPasses()");
}
}
选择一个单元测试方法,然后点击 [Run Selected]。或者直接点击 [Run All]。