From 90f0e69499073f21f1216953951d7f3e950ce7c1 Mon Sep 17 00:00:00 2001 From: Ale Mohamad Date: Tue, 21 Jan 2025 15:59:23 +0100 Subject: [PATCH] Adjustments from PR comments. --- docs/advanced/testing.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/docs/advanced/testing.md b/docs/advanced/testing.md index 20aee771..713d3772 100644 --- a/docs/advanced/testing.md +++ b/docs/advanced/testing.md @@ -5,7 +5,7 @@ Vapor includes a module named `VaporTesting` that provides test helpers built on `Swift Testing`. These testing helpers allow you to send test requests to your Vapor application programmatically or running over an HTTP server. !!! note - For newer projects or teams adopting Swift concurrency, `VaporTesting` is highly recommended due to its simplicity and integration with Vapor. + For newer projects or teams adopting Swift concurrency, `Swift Testing` is highly recommended over `XCTest`. ### Getting Started @@ -54,10 +54,6 @@ To ensure your tests run in a serialized manner (e.g., when testing with a datab @Suite("App Tests with DB", .serialized) ``` -#### Running Tests - -Use `cmd+u` with the `-Package` scheme selected to run tests in Xcode. Use `swift test --enable-test-discovery` to test via the CLI. - ### Testable Application Define a private method function `withApp` to streamline and standardize the setup and teardown for our tests. This method encapsulates the lifecycle management of the `Application` instance, ensuring that the application is properly initialized, configured, and shut down for each test. @@ -204,13 +200,10 @@ final class MyTests: XCTestCase { Each function beginning with `test` will run automatically when your app is tested. -#### Running Tests - -Use `cmd+u` with the `-Package` scheme selected to run tests in Xcode. Use `swift test --enable-test-discovery` to test via the CLI. - ### Testable Application Initialize an instance of `Application` using the `.testing` environment. You must call `app.shutdown()` before this application deinitializes. + The shutdown is necessary to help release the resources that the app has claimed. In particular it is important to release the threads the application requests at startup. If you do not call `shutdown()` on the app after each unit test, you may find your test suite crash with a precondition failure when allocating threads for a new instance of `Application`. ```swift