forked from mgants4/SharpUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Unit testing framework for Unity3D in C#
License
firekat/SharpUnit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
20 May 2010 Mark Gants | [email protected] SharpUnit is a unit testing framework written in C# specifically for Unity3D. It was inspired by and adapted from UUnit, which is written in Boo. More info on UUnit can be found here: http://www.unifycommunity.com/wiki/index.php?title=SharpUnit Why SharpUnit? - Because NUnit is not so easy to integrate into Unity3D. - UUnit works but, while I personally like Boo, not everyone is familiar/comfortable with programming in Boo. - SharpUnit allows you to trap/expect exceptions, UUnit does not (as of today). - SharpUnit can easily be integrated into Unity3D but is not dependant on the Unity3DEngine namespace. - SharpUnit can easily extended and tested outside of Unity3D and even be used for other purposes. - SharpUnit is straight-forward and easy to use. Getting Started: - The Visual Studio solution contains two projects: SharpUnit and SharpUnitTest - SharpUnit: This is the class library that can be built to a DLL. - SharpUnitTest: This is a console app that runs the unit tests for SharpUnit itself. - The Main() function in Program.cs is an example test runner, it illustrates how to get up and running with SharpUnit. - The Unity3D_SharpUnitDemo.zip file contains an actual Unity3D 2.6 project using SharpUnit. Integrate with Unity3D Using a DLL: - Build the SharpUnit.dll from source using Visual Studio. - Create a folder named "SharpUnit" In your Unity3D project's "Assets" folder. - Place the SharpUnit.dll in this folder. - Copy the Unity3D_TestRunner.cs and Unity3D_TestReporter.cs files to this folder. Integrate with Unity3D Using the Scripts: - Create a folder named "SharpUnit" In your Unity3D project's "Assets" folder. - Copy the SharpUnit class files (*.cs) to this folder. - Copy the Unity3D_TestRunner.cs and Unity3D_TestReporter.cs files to this folder. Running Tests in Unity3D: - Create an empty GameObject within Unity, name it TestRunner. - Drag the Unity3D_TestRunner.cs script onto the TestRunner game object. - Write unit test scripts as classes derived from the TestCase class. - Configure the TestSuite object in the Unity3D_TestRunner.cs script to run your tests. - Press Play, you should see the test output in the Unity3D editor console. Extending SharpUnit: - Derive a new class from TestReporter to modify how SharpUnit reports test results and errors. Tips & Tricks: - Depending on your project and how you write your tests, you might notice that SharpUnit can leave "extra" or "duplicate" objects in your scene. This tends to happen if you don't clean up after your tests in the "tear down" methods or if you make use of automatic Singletons, etc. To mitigate this, consider opening a fresh scene before you run the unit tests and close it after the tests have run. I recommend automating this with a static method labeled as a Unity editor "menu item." Works well when running tests in the editor or as part of of your build process as it keeps your scenes free of extra test artifacts that may appear. More on menu items: http://unity3d.com/support/documentation/ScriptReference/MenuItem.html
About
Unit testing framework for Unity3D in C#
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published