Skip to content

XCode configuration guide

Derek Clarkson edited this page Nov 16, 2022 · 2 revisions

Using Voodoo in Xcode is pretty straight forward. You can handle the setup in the setUp() function override if all the tests in the suite need the same configuration, and perhaps tweak some responses in individual tests. Alternatively if the tests are too different in their requirements you can simply start the server inside each tests.

Either way if you take a look at the Xcode samples you will find a sample XCTestCase that is both simple and flexible in how you can use it.

The summary of using Voodoo in a test suite is:

  1. In the setUp() of your UI test suite you start and configure an instance of Voodoo.

  2. Using a launch argument, pass Voodoo's URL to your app. It's important to launch Voodoo before your app for two reasons. One to get and pass the URL, but also because if your app makes any calls during startup, that Voodoo is already configured and ready to handle them.

  3. Finally in teardown() clear the Voodoo instance otherwise Voodoo and the port will stay allocated until the end of the test run.

    Note that I said "test run". Remember XCTest creates a new instance of the XCTestCase for each test within it, and it also keeps all of them in memory until the entire test run finishes. This means that if you do not dealloc Voodoo in teardown() it will stay there consuming ports until the end of the test run and resulting in you running out of ports very fast.

Clone this wiki locally