Creating a Consistent Testing Environment
Next, you will write tests for ScheduleFetcher. To get started, create a new Swift source file in the RanchForecastTests called ScheduleFetcherTests.swift. In the file, add a new class ScheduleFetcherTests, a subclass of XCTestCase.
import Foundationimport XCTest import RanchForecast class ScheduleFetcherTests: XCTestCase { }
Before you can write any tests against ScheduleFetcher,
you need to make sure that the class itself is visible
from the RanchForecastTests target.
You already imported the RanchForecast target
into ScheduleFetcherTests.swift,
but you still need to mark the class and its initializer public
.
Edit ScheduleFetcher.swift as follows:
public class ScheduleFetcher { enum ...
Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.