Is anyone doing unit testing with Unity code? I’d like to do it, but I just see lots of problems with it due to all the global state… for example:
Current scene, as loaded through the globally available Application static members. Lots of ways everywhere to access this global state (FindObjectsOfType etc, even static methods).
Static accessors for Camera, Terrain, etc.
Physics state, “transitively” available through static methods in Physics class.
Anyone that can give some hints on how to do reasonable amounts of unit testing, while not losing the productivity of Unity completely?
It’s a bit weird really. I really like the idea of unit testing and reusable code… but people still churn out excellent Unity products that (I assume) have completely untestable (automated testing-wise) code. So are unit tests overkill for Unity game code?
Can’t really make up my mind. How do you see it? Can unit testing and Unity be friends?
But it doesn’t really address the issue of Unity’s massive global state clashing with the opportunity to instantiate a small portion of your application, and run it isolated.
I tried SharpUnit and the other stuff on this subject but nothing really worked for me. SharpUnit is cool but I didn’t want so much stuff written to the console, and I wanted to be able to test multiple scenes etc…
So we wrote TestStar. It might be interesting if you want to try doing more testing. You can also watch an <5min video showing off some of the cool things it does.