Ok, we have now exercise more of our feature’s logic and behavior in a simple unit test. We can emulate the user tapping on various buttons and typing into text fields to add a new player to their game, and then we assert that indeed the game was added to the model’s state. We can now be very confident that this feature works when run in the simulator or on device, as long as the view is reading the state from the model to construct its hierarchy and as long as the view is calling the model’s methods when the user takes an action.
Things are looking good, but there are some improvements we can make to this. We had to copy-and-paste quite a bit of set up code in that test just to get to a point where we could actually start emulating user behavior and making assertions. And the assertion itself was quite verbose. We are going to make both of those aspects much better, and we are going to take a look at how we can use AI to write a few more tests for us.
Let’s take a look.