Wait for something to happen within integration test?

Hey there, I want to test the initialisation of a UMA character. So the test has to wait until the character was created. This is no problem as there is a callback method for this. I also want to test things that happen within the callback method though. How do you accomplish something like “wait until this and that has happened and then go on with the test”?

Greetings

A Coroutine…

while(!hasHappened)

// do stuff
hasHappened = true;


yield return wait for seconds(.01)

// go do more stuff since that's happened

once hasHappened is true, coroutine ends and whatever comes after the yield can execute. If the time coupling is loose, you can use InvokeRepeating to wake up, look for state change and do something if it has.

Another pattern I’m starting to use is events and delegates, you can setup an event for the onHappenedEvent.

Hope it makes sense, still having morning coffee

It’s up to you to tell the test that it finished. For an integration test you need to explicitly call a method to pass or fail the tests. Can’t you do that in the callback method? (or I don’t understand something :)?)