From 3dcc9498c7430d3ce786ed3889088ac32407adcd Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Sun, 13 Nov 2016 16:36:49 -0500 Subject: [PATCH] explicit testable import --- testing/basic.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testing/basic.md b/testing/basic.md index 1c3a5a3b..d70d1cc0 100644 --- a/testing/basic.md +++ b/testing/basic.md @@ -48,7 +48,7 @@ drop.run() The first thing we'll do is in my testing target, add a file called `Droplet+Test.swift`. It will look like this: ```swift -import Vapor +@testable import Vapor func makeTestDroplet() throws -> Droplet { let drop = Droplet(arguments: ["dummy/path/", "prepare"], ...) @@ -58,7 +58,7 @@ func makeTestDroplet() throws -> Droplet { } ``` -This looks a lot like our initializer in `main.swift`, but there are 2 very key differences. +This looks a lot like our initializer in `main.swift`, but there are 3 very key differences. ### Droplet(arguments: ["dummy/path/", "prepare"], ... @@ -68,6 +68,10 @@ The `arguments:` parameter in our `Droplet` creation. This is rarely used except You'll notice here that we're calling `runCommands()` instead of `run()`. This allows the `Droplet` to do all the setup it would normally do before booting without actually binding to a socket or exiting. +### `@testable import Vapor` + +We'll need to import the testable compilation of Vapor to access the `runCommands` function. This is currently not public as a protection against accidental bugs in live apps. + ## Test Our Droplet Now that all of this has been created, we're ready to start testing our application's `Droplet`. Here's how a really basic test might look: