As far as I can tell, an expectation is some sort of timer, and if time runs out then the test that contains the expectation will fail–the expectation is not connected to any code. Other code, running in another thread/process, then tries to stop the timer before it expires–by calling fulfill().
I imagine our situation is something like this:
Thread 1 Thread 2 ======== ========= -app compiles -app launches -code executes code executes -tests execute... code executes -create expectation code executes -sleep(5) ^ code executes | code executes +====== webViewDidFinishLoad() executes fufill()
My question is: why can’t webViewDidFinishLoad(_:) execute before the expectation even gets created?