Debugging tests

- [Instructor] In our last lesson…we wrote ourselves some unit tests…and we went ahead and we tested them.…And, while one of them passed, the other one failed.…And we need to find out why this one failed.…So, what you typically want to do…when you're debugging in Xcode,…is set a breakpoint and trace out…where the code is going wrong.…And when you're working with your unit test,…this is no different.…So what I'm going to do,…because testIncrement is failing,…I'm going to set a breakpoint over here…and rerun this test.…

Let's take a look at what happens.…All right.…So, as the test runs, it catches my breakpoint.…It's pretty cool that you can set breakpoints…inside of your test to figure out what's going on.…We see here that it stopped…on our IncrementCount function and ProductManager.…Let's go ahead and step into that one…by clicking the downward arrow that appears on the tool bar.…So we step into this function…and we see here that first we're getting a count,…and it's using the countFor function.…

So, it gets an initial count.…

Resume Transcript Auto-Scroll

Author

Released

1/23/2018

Implementing automated testing practices in your Xcode projects can help you collaborate with your colleagues more efficiently, speed up your development time, and reduce bugs. In this course, instructor Ron Buencamino dives into the topic of automated testing, with a focus on unit tests and user interface (UI) tests in Xcode. After Ron goes over the basics of unit and UI tests—including why automated testing is important—he covers unit tests, explaining how to create test targets; write, run, and debug tests; and mock HTTP response data. He then moves on to UI testing, discussing UI recording, code coverage, and how to write UI tests.