Automatic creation and deletion of test objects in unit tests

Hi !
I’m looking for a way to regroup creation and deletion of the objects I’m testing in my unit tests. The result I’m looking for is something like this :

class TestClass
GameObject t1=null;
void createObject()
   t1 = new GameObject();
void DestroyObject()
void testCase()


I’m looking for an automated way to have the test runner call createObject() before a call to testCase, and to call DestroyObject after the call, regardless of test result.
I know this exists in unit testing, I just have no idea what it’s called and my searches have turned up nothing.
I found [Datapoint] in the examples, it looks like what I’m looking for, but I’m unable to find documentation about its use.

From what I’ve seen, these are usually refered to as “setup” and “teardown” methods - these are your @before and @after methods from Java’s Junit, and [SetUp] and [TearDown] from the .Net library NUnit.

That might not be available in the default unit testing library from Unity - I couldn’t find it through some light googling. That would be a shame, though, as those methods - especially the SetUp method - are really really usefull.

You have two choices, if that’s the case. The first is to try to use a ported NUnit, as laid out in this forum post.

The other one is to just live with it, and call SetUp(); and TearDown(); manually in each unit test.

EDIT: looking at the Unity Test Tools package, it seems like they’re building on NUnit, so it might be that those constructions are already in - see an example here. I can’t get Visual Studio or MonoDevelop to actually compile the example tests from the test tools, so there’s that.