TDD
UnityでTest書く
- Window -> General -> TestRunner
- EditModeタブ、[Create Test Assembly Folder]押す
原則 RED→GREEN→REFACTER→RED...
- まずテストを書き、エラーになることを確認して、
- 実装して、エラーを解消。
- 実装をリファクタ
using NUnit.FrameWork; using Unity.Engine; public class HogeTest { [Test] [TestCase(3)] [TestCase(6)] public void GetHogeTest(int num) { var hoge = new Hoge(); var value = new hoge.GetHoge(num); Assert.AreEqual("Hoge", value); } } public class Hoge { public string GetHoge(int num) { if(num % 3 == 0){ return "Hoge";} return ""; } }
なんかこんなかんじ