Reputation: 223
I am trying to write UI Unit Test cases for iOS. But the tests never run and give failures. The test ran successfully for a couple of times and then started failing even though I didn't made any changes in the code. The app launches in the simulator and then closes giving failures. Its a very complex app, both UI and feature wise and also almost all the data of the UI is dynamic. For example all the images, label texts, number of rows in the tables etc are getting fetched from API responses. If someone could please suggest a good tutorial with elaborate explanation or the reason for this random behaviour, it will be a great help. I have already gone through the WWDC tutorials and many tutorials on youtube.
Upvotes: 0
Views: 203
Reputation: 166
During testing you should own all the data in order for the tests to be deterministic and always run with the same results. If you fetch your data dynamically from the network or elsewhere you can never know when the data will change, making your tests fail.
Generally you should somehow mock you data. Which approach makes best sense for your project I don't know, because you don't give any details. But here is an example from Joe Masilotti for how to mock your network communication: UI Testing with Stubbed Network Data
Upvotes: 1