dwyl / learn-apple-watch-development

:green_book: Learn how to build Native Apple Watch (+iPhone) apps from scratch!
55 stars 5 forks source link

UI Testing in XCode #39

Open sohilpandya opened 7 years ago

sohilpandya commented 7 years ago

Attaching my findings on using UI Tests.

I've been researching UI Automation testing and XCode comes built in with the automation tools which will allow a user to do UI Testing.

The idea is very much like Daydream, where you start recording the user's movement through the screen and where they end up. The user can then test whether the action taken by the user has had any effect.

What was my plan?

I set out a simple goal of being able to track the user when they add a new project. The steps required for this are:

How?

As long as we have UITest set up as a target for the project, it is straight forward to begin your journey in automation UI Testing.

This will open up the simulator and it will now record every click that is made by you and convert it into code inside of testExample()

Issues Here is where we come across our the first issue, when we record the test, delete the code and repeat the process, it creates a different set of code. 😟 For e.g.

// First time
//        let app = XCUIApplication() // This is one of the issues that pops up in UI Testing.
// Second time
//        let app = app2

Issues Here is where the next issue arises, the test created above where the user enters "Test" sometimes results in the automation test typing in "Est", "Tes", "es" but never the full word "Test". This means the test never passes.

 Next steps

nelsonic commented 7 years ago

@sohilpandya this deserves it's own mini-tutorial (markdown file + screencast). excited to see it! 🎉

sohilpandya commented 7 years ago

update