Hello,
I am developing an Unity package that uses Adventure Creator. I would like to write unit tests using the Unity's unit testing framework. How should I go about building the tests? How easy is it to "mock" the AC scene with global variables? Or should I create an empty scene and load that in the beginning of the test?
I have done something like this, already. How to go about adding global variables in this case? Thank you!
[SetUp]
public void Setup()
{
if (EventSystem.current == null) {
EventSystem.current = new GameObject("EventSystem", typeof(EventSystem), typeof(StandaloneInputModule)).GetComponent<EventSystem>();
}
var ks = new KickStarter();
ks.Initialise();
go = new GameObject();
target = go.AddComponent<NGHMenu>();
// combine path with test directory
target.hintsPath = Path.Combine(TestHelper.GetTestDirectory(), "fixtures", "test01");
CreateSampleObject();
target.guideSample = sampleObject;
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
For an AC scene to run correctly, you need:
The GameEngine object includes the KickStarter component, as well as other components that handle scene-specific data and behaviour. You can either add the prefab from AC's Prefab/Automatic folder, or view it to see what components need to be manually added.
Thank you for the direction where to go. I managed to setup the AC GameEngine like this:
This creates the
SceneManager
object and the requiredMainCamera
. TheInitialiseObjects
will then create the necessary components. No scene file needed or anything. And theKickStarter
now has the managers in place and I can do this inside the test, for example:Hope this helps someone facing the same situation.