-
Notifications
You must be signed in to change notification settings - Fork 62
Unit testing
Evgenii Neumerzhitckii edited this page Jun 12, 2015
·
10 revisions
This class is for testing the code that uses Dodo. It helps verifying the messages that were shown in the message bar without actually showing them.
Here is how to use it in your unit test.
- 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])