-
Notifications
You must be signed in to change notification settings - Fork 61
Unit testing
Evgenii Neumerzhitckii edited this page Jun 18, 2015
·
10 revisions
Compilation of the Gelderland sketches, 1601. Source: Wikimedia Commons.
Dodo has a built-in DodoMock
class that will help you verify the messages in unit tests.
- Create an instance of DodoMock.
- Set it to the
view.dodo
property of the view. - Run the code that you are testing.
- Finally, verify which messages were shown in the message bar.
// Supply mock to the view
let dodoMock = DodoMock()
view.dodo = dodoMock
// Run the code from the app
runSomeAppCode()
// Verify the message is visible
XCTAssert(dodoMock.results.visible)
// Check total number of messages shown
XCTAssertEqual(1, dodoMock.results.total)
// Verify the text of the success message
XCTAssertEqual("To be prepared is half the victory.", dodoMock.results.success[0])