Testing a Vapor application is same as testing a Swift package. In Chapter 1, Getting Started with Server Swift, you got a primer on Swift packages, and you wrote your first test for that package. Writing test is very similar, and our Vapor application comes with some dummy tests. If we look at the Test/AppTests folder, we will see the following two files:
- RouteTests.swift
- Utilities.swift
RouteTests.swift contains two tests that test the routes of our Vapor application and ensure that the output we are getting from our Vapor app is what we expect to get. For Swift to run our test, we will need to start up the server, and, for that, we will need to define some helper extension methods on the Droplet class, and those are defined in the Utilities.swift file, where it creates a Droplet configured with the test environment, as follows...