December 2018
Intermediate to advanced
414 pages
10h 19m
English
Let's consider a TaskManager class that has NetworkService as a collaborator; the tasks are stored locally until the user decides to save them on a server by tapping on a synchronization button. Basically, we have two different behaviours in the class, and we want to test them in different scenarios.
However, when we test one of these behaviors, we need to take the other into account somehow. The code could be something similar to this:
class TaskManager { private var tasks = [Task]() private let service: TaskManagerService init(service: TaskManagerService) { self.service = service } func add(task: Task) { tasks.append(task) } var count: Int { return tasks.count } func sync() ...Read now
Unlock full access