Skip to content

Commit

Permalink
Adjustments from PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
alemohamad committed Jan 21, 2025
1 parent 74128ea commit 90f0e69
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions docs/advanced/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 90f0e69

Please sign in to comment.