November 2018
Intermediate to advanced
404 pages
10h 16m
English
Now you're ready to add your own unit tests to the Vapor 3 project you created in the last chapter. Previously, you added a new route called "student" and your web application allows a user to query for a student's record that was stored in the array studentRecords. You can add a unit test to AppTests.swift and check if this feature works as expected:
@testable import App // [1]import XCTestimport Vapor // [2]final class AppTests: XCTestCase { func testNothing() throws { // add your tests here XCTAssert(true) } func testStudent() throws { // [3] let myApp = try app(Environment.testing) // [4] let studentRecords = [ // [5] "Peter" : 3.42, "Thomas" : 2.98, "Jane" : 3.91, "Ryan" : 4.00, "Kyle" : 4.00 ]Read now
Unlock full access