Skip to content

Unit testing

Evgenii Neumerzhitckii edited this page Nov 9, 2015 · 10 revisions
Compilation of the Gelderland dodo sketches from 1601 of live and recently killed dodos.

Compilation of the Gelderland dodo sketches, 1601. Source: Wikimedia Commons.

Usage

Dodo has a built-in DodoMock class that will help you verify the messages in unit tests.

  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