Last active
December 14, 2015 11:58
-
-
Save sassembla/5082797 to your computer and use it in GitHub Desktop.
Unity's plugin testkit. Minimum.
Run automatically in UnityEditor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
[InitializeOnLoad] | |
public class UnityEditorTestKit : MonoBehaviour { | |
static UnityEditorTestKit () { | |
testRun(); | |
} | |
static void Assert(bool condition, string message) { | |
if (!condition) throw new Exception(message); | |
} | |
/** | |
run tests | |
*/ | |
static void testRun () { | |
/* | |
setUp | |
*/ | |
Action setUp = () => { | |
Debug.Log("test setUp"); | |
}; | |
/* | |
tearDown | |
*/ | |
Action tearDown = () => { | |
Debug.Log("test tearDown"); | |
}; | |
Debug.Log("test start"); | |
var testList = new List<Action>(); | |
collectTestsTo(testList); | |
// check avail:count, type, condition | |
foreach (var currentTest in testList) { | |
setUp(); | |
currentTest(); | |
tearDown(); | |
} | |
Debug.Log("test over"); | |
} | |
/** | |
test cases | |
*/ | |
static void collectTestsTo (List<Action> testList) { | |
// | | |
// TEST HERE \|/ | |
testList.Add( | |
() => { | |
Debug.Log("the 1st test case"); | |
Assert(true, "yeahh-hooo"); | |
} | |
); | |
testList.Add( | |
() => { | |
Debug.Log("the 2nd test case"); | |
Assert(false, "should be failure"); | |
} | |
); | |
// TEST HERE /|\ | |
// | | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated.
delegateをinvokeするのではなく、Actionに切り替え。