Function
withApp(_:)
Perform a test while handling lifecycle of the application. Feel free to create a custom function like this, tailored to your project.
@discardableResult func withApp<T>(_ test: (Application) async throws -> T) async throws -> T
Discussion
Usage:
@Test
func helloWorld() async throws {
try await withApp { app in
try await app.testing().test(.GET, "hello", afterResponse: { res async in
#expect(res.status == .ok)
#expect(res.body.string == "Hello, world!")
})
}
}