Testing the Vapor application

Testing a Vapor application is same as testing a Swift package. In Chapter 1Getting 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 ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.