UnitTest 설정 방법
Window -> General -> TestRunner 클릭 한다.

TestRunner 라는 창이 생성 된다.
PlayMode 와 EditMode 가 있는데,
PlayMode는 Unity가 플레이 됬을 때 테스트 하는 방법 이고,
EditMode는 Unity가 플레이 되지 않았을 때도 테스트가 가능한 방법이다.
일단 EditMode로 먼저 UnitTest를 만들어 본다.
Create EditMode Test Assembly Folder 클릭

Tests 라는 폴더가 생성 되며

TestRunner 창이 바뀐다.
Create Test Script in current folder 클릭

Assets/Tests 폴더 안에 Tests.asmdef 파일 과, NewTestScript 라는 스크립트가 생성 되고

Test Runner 창이 또 바뀌게 된다.

스크립트 내용은 아래 와 같다.
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
namespace Tests
{
public class NewTestScript
{
// A Test behaves as an ordinary method
[Test]
public void NewTestScriptSimplePasses()
{
// Use the Assert class to test conditions
}
// 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 NewTestScriptWithEnumeratorPasses()
{
// Use the Assert class to test conditions.
// Use yield to skip a frame.
yield return null;
}
}
}
TestRunner 창에서 RunAll을 클릭 해 보면

단위테스트가 진행 되어 이상이 없음을 나타낸다. ClearResults를 클릭하면 테스트 결과가 사라진다.

'Unity3d' 카테고리의 다른 글
[Unity3D] UnitTest UnityManual 에 있는 걸로 테스트 해보기 (0) | 2021.05.12 |
---|---|
[Unity3D] Animator 관련 IsPlaying / GetName / GetTime (0) | 2021.03.25 |
[Unity3d] C# string.Format 을 사용하여 소수점, 돈 재화 1000단위 콤마(,) 표시하기 (0) | 2021.02.18 |
[Unity3d] UI Canvas Horizontal Layout 사이즈를 벗어나지 않고 이미지 더 생성하기 (0) | 2020.07.25 |
[Unity3d] C# int 형식 초를 시간형식 string 으로 변경하는 간단한 방법 int -> HH:MM:SS 형식으로 변경하기 (0) | 2020.07.23 |
댓글