Introduction to Testing in iOS - raywenderlich.com
1,366 views · Published 8 January 2018 · 2:14 · Indexed 26 October 2026
Channel: Kodeco · 2018 · Education
Part of writing code is testing your code and thankfully, Xcode comes with a bevy of awesome tools. This video will give you an overview of testing. View the full course here: https://www.raywenderlich.com/181326/updated-course-testing-in-ios ---- About www.raywenderlich.com: raywenderlich.com is a website focused on developing high quality programming tutorials. Our goal is to take the coolest and most challenging topics and make them easy for everyone to learn – so we can all make amazing apps. We are also focused on developing a strong community. Our goal is to help each other reach our dreams through friendship and cooperation. As you can see below, a bunch of us have joined forces to make this happen: authors, editors, subject matter experts, app reviewers, and most importantly our amazing readers! --- Writing tests isn’t glamorous, but since tests can keep your sparkling app from turning into a bug-ridden piece of junk, it sure is necessary. If you’re reading this iOS Unit Testing and UI Testing tutorial, you already know you should write tests for your code and UI, but you’re not sure how to test in Xcode. Maybe you already have a “working” app but no tests set up for it, and you want to be able to test any changes when you extend the app. Maybe you have some tests written, but aren’t sure whether they’re the right tests. Or maybe you’re working on your app now and want to test as you go. This iOS Unit Testing and UI Testing tutorial shows how to use Xcode’s test navigator to test an app’s model and asynchronous methods, how to fake interactions with library or system objects by using stubs and mocks, how to test UI and performance, and how to use the code coverage tool. Along the way, you’ll pick up some of the vocabulary used by testing ninjas, and by the end of this tutorial you’ll be injecting dependencies into your System Under Test (SUT) with aplomb! Testing, Testing … What to Test? Before writing any tests, it’s important to start with the basics: what do you need to test? If your goal is to extend an existing app, you should first write tests for any component you plan to change. More generally, tests should cover: Core functionality: model classes and methods, and their interactions with the controller The most common UI workflows Boundary conditions Bug fixes First Things FIRST: Best Practices for Testing The acronym FIRST describes a concise set of criteria for effective unit tests. Those criteria are: Fast: Tests should run quickly, so people won’t mind running them. Independent/Isolated: Tests should not do setup or teardown for one another. Repeatable: You should obtain the same results every time you run a test. External data providers and concurrency issues could cause intermittent failures. Self-validating: Tests should be fully automated; the output should be either “pass” or “fail”, rather than a programmer’s interpretation of a log file. Timely: Ideally, tests should be written just before you write the production code they test. Following the FIRST principles will keep your tests clear and helpful, instead of turning into roadblocks for your app. Xcode provides you with capabilities for extensive software testing. Testing your projects enhances robustness, reduces bugs, and speeds the acceptance of your products for distribution and sale. Well-tested apps that perform as expected improve user satisfaction. Testing can also help you develop your apps faster and further, with less wasted effort, and can be used to help multiperson development efforts stay coordinated. At a Glance In this document you’ll learn how to use the testing features included in Xcode. The XCTest framework is automatically linked by all new test targets. Quick Start. Beginning with Xcode 5 and the introduction of the XCTest framework, the process of configuring projects for testing has been streamlined and automated with the test navigator to ease bringing tests up and running. Performance Measurement. Xcode 6 and later includes the ability to create tests that allow you to measure and track performance changes against a baseline. UI Testing. Xcode 7 adds capabilities for writing tests that exercise an app’s UI. It includes the ability to record UI interactions into source code that you can transform into tests. Continuous Integration and Xcode Server. Xcode tests can be executed using command-line scripts or configured to be executed by bots on a Mac running Xcode Server automatically
More from this channel
-
0:28
The Ant and The Chrysalis | Wild Fables
-
0:45
Cocos2D Via Minigames Workshop Trailer
-
0:13
Wild Fables | Crane Neck Experiment
-
1:11
iOS Winter Wonderland
-
0:36
The Country Mouse and the City Mouse | Wild Fables
-
1:24
The iOS Christmas Song
-
1:13
iOS Games by Tutorials: Juice Your Game
-
1:00:36
January 2015 Tech Talk: WatchKit