UUnit is a simple xUnit-style framework for unit testing inside Unity IDE.
NUnit (a popular unit-testing framework for all .NET languages) may seem like a good fit for Unity, but doesn't mesh well. In particular, NUnit is designed to be called from the console or run on a windows GUI. NUnitLite is designed for IDEs like Unity but is not included in the Unity Package; to be run easily and portably between projects it needs to included in assets. Unfortunately, NUnitlite does not put each class in a file of the same name so Unity will not load the files. Thus, the need for UUnit.
To run its own tests attach "RunnerTestCase" to an object and it's start method will run the test cases on UUnit. Output goes to Debug.Log. To make your own test cases use "TestCaseTest" as exmple. the "[Test]" attribute marks tests and if the class is added to the suite all methods with a Void return and no paramaters signature will be run.example runner code is below.
suite.AddAll(TestCaseTest()) # AddAll [Test] methods in TestCaseTest
result = suite.Run(null) # run all tests
xUnit programs do not normally show successful tests only failures. So debug log show only 6 test run. To find out what is running you will have to check the code. In RunnerTestCase, the following is the line which adds tests to the test suite:
If you look at TestCaseTest.boo you will see it has 6 methods with [Test] attribute in front of them. These are what is run.
Also in the debug log you will 3 lines with Dummy Fail. This is what shows when a test fails. The reason the output says 0 fail even though there are 3 failures above it is that I am testing the framework to see that the failure mechanism works correctly and it produced fail trigger when it was supposed to so they do not show up in the final output as failures.
July 1 2008
0.3 release by hatsix
- standardized filenames
- separated the test files from the UUnit files to facilitate new user understanding
- added UUnitAssertException, to help standardize the output of failed assertions.
- changed the logging function for failed tests, much more readable now (no more InvocationException)
Original 0.2 release by ryuuguu