I have a use case where the following is needed, and in the following order:
1. Wait for a complex UI component to construct (Done)
2. Wait for a login, and store token to be used in other tests. (Done).
3. Test asyncronous server call results independently. (Done)
4. Re-Model data from two asyncrous calls that can be returned in any oder (HELP!!!)
I have one call that pulls objects from a database and I have a nice list from the result of one of the methods. I have anothe call that pulls different objects from a database and I have a nice list from that result.
Now I have a class that performs grouping the two lists together in a tree after the first two execute. How do I test this?
I can't add an async handler method because I can't wait for the first two async methods to complete.
I can't create one test and add 3 async methods to the test because the 3rd is dependent on the first two, and the first two could come back in any order (Error is thrown when an async test comes back out of order).
Well, this is outside of the intended use case so you are going to need to do a bit of work on your own, but you can make it work.
Basically, you will need to make yourself an object used just for testing, let's call it TestDataManager for my purposes. The TestDataManager will listen for the results of your multiple asynchronous calls. Internally it can do any business logic to handle situations where one may come back first or second, etc. Once it has all of the data combined, then it will dispatch its own event.
When you write your test, have the test pend on the asynchronous event coming from the TestDataManager as opposed to the individual events coming back from the service.
Thanks. That suggestion worked.