Git Product home page Git Product logo

sharpunit's Introduction

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

sharpunit's People

Contributors

ken39arg avatar acidlemon avatar

Stargazers

uzzu avatar Ecky Putrady avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.