- Home /
Unity Test Tools - Integration Test for existing scenes
We are wanting to use integration tests and load each level (scene) in our game to see if any errors occur. It seems like the built-in integration testing requires a new scene, so how would I set this up?
Is there a way to do this with Unity Test Tools?
Not sure what you are asking. Integration tools use a single, special, test scene. What are you trying to test?
We just want to launch every level in our game with CI and fail if there are any exceptions in the log, etc. We feel like this would be helpful for catching mistakes. We are already running NUnit tests and some specific integration tests (but these are not in the same scene as a level).
There isn't a current functionality for that as far as I am aware. We will look into this.
Thanks. Is there a way to launch a scene with the NUnit runner? Or is it so far removed from running the Unity engine that it wouldn't work?
Running a whole scene is somewhat out of the focus of NUnit. NUnit is intended for testing units of code. A whole scene is somewhat the domain of Integration Tests - as you are probably going to be testing how integrated particular concepts are within the scene itself.
Answer by dittytwo · Oct 02, 2015 at 11:57 AM
Hi there
ok first create a new integration test scene with a new empty object create one called level manager create a level manager script and load to the level manager that will load a new scene add a new integration test and add a test script that calls the level manager to load the scenes one by one reading the log for errors after each one.
would this not work... (I am not sure if your controlling test script would then be out of focus for the unite engine and therefore never finish but its worth a try.)
So the last time I looked at this, as soon as a new scene was load (even loaded additive), the tests would all cancel and the integration test runner would completely reset.
There have been a lot of updates to Unity Test Tools since I tried this, though. This might be something that works now. I'll have to try it out when I have time.
I am trying to do something similar with, 5.3.2 and up to date Test Tools. We have a main scene which has a lot of controllers that need to be all loaded up (and initialized) together in order to properly test some of the code. We load it up, and the test ends immediately.
In theory, I'd like to be able to call a loadscene (additive) and pop in everything that comes in our main scene, then act on that scene while it is loaded.
I've got past your problem by setting DontDestroyOnLoad on the TestComponent and TestRunner. This allows you to load scenes and operate tests on those scenes. It then loses the neat functionality of cleaning up the scenes after each test is performed.... And i've just noticed that the batch$$anonymous$$ode runner doesnt build the all the levels, only the ones specified in the cmd args. Feels like this system needs a bit more "real world" work.