From the course: Learning Combine with Swift
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Unit testing and Combine - Swift Tutorial
From the course: Learning Combine with Swift
Unit testing and Combine
- [Instructor] As a methodical Swift developer, it is important that you always ship tested code and this especially holds true when working with remote services through frameworks such as Combine. In this video, we're going to explore unit testing with Combine. Let's begin. As a Swift developer, you should not only write test cases for synchronous functions, but also asynchronous functions such as API calls. But how do you do unit testing in Combine? Well surprisingly, it's not that hard. Testing publishers involves creating subscribers that observe your publishers and like with any typical Swift testing approach, you then use assertion functions like you would normally do. The easiest way to demonstrate this would be to jump straight into the code. In this video's exercise file, I make use of an existing class called APIService. But before we look into that, let's start off first with our tests as we would like…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.