Skip to content

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.

  1. Create an instance of DodoMock.
  2. Set it to the view.dodo property of the view.
  3. Run the code that you are testing.
  4. Finally, verify which messages were shown in the message bar.

Example

// 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])
Clone this wiki locally