Testing Asynchronously
We’ve learned how to test that parts of our user interface show what they’re supposed to, and that’s really useful. However, the whole point of this scene is to play an audio file, and we would also like to get some test coverage of that functionality. In other words, when we call handlePlayPauseTapped, what proves that anything is playing?
Back in the ViewController class where we have all the controller logic for the scene, we had an AVPlayer that’s responsible for playing the audio. It has a currentTime method that tells us how far into the current media item it has gotten. So this seems straightforward: we write a test to tap the Play button, then check that the current time isn’t 0.
First things first…back in
Get iOS 10 SDK Development, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.