Skip to content

Update Queues Testing Section #1140

@liltimtim

Description

@liltimtim

Please summarize your feature request

Update testing queues documentation to reflect Swift Testing framework

Describe the functionality you're seeking in more detail

Current documentation for testing queues https://docs.vapor.codes/advanced/queues/#testing could be updated to support Swift Testing framework as Apple is moving towards this methodology anyway see this link.

Steps to Compiling

  1. In Package.swift add the following package:
.package(url: "https://github.com/vapor/queues", from: "1.18.0")
  1. In Package.swift add to executable package
.product(name: "Queues", package: "queues")
  1. Add this to the test target as well
        .testTarget(
            name: "queues_appTests",
            dependencies: [
                .target(name: "<your_app_name_here>"),
                .product(name: "VaporTesting", package: "vapor"),
                .product(name: "XCTQueues", package: "queues")
            ],
            swiftSettings: swiftSettings
        )

Example Test File That Compiles

import VaporTesting
import Testing
import XCTQueues

@Suite("Queues Tests")
struct QueuesAppTests {
    
    @Test("Setup and Test Queue")
    func setupAndTestQueue() async throws {
        let app = try await Application.make(.testing)
        defer {
            Task {
                try await app.asyncShutdown()
            }
        }
        app.queues.use(.asyncTest)
        try await configure(app)
    }
}

Have you considered any alternatives?

There really isn't an alternative that I could find to get my test suite compiling besides digging and configuring the testing harness in a way that made Swift Testing happy.

I tried using the current documentation to setup queues testing in the Swift Testing methodology but it does not compile because it could not find the correct XCTQueues package which provides the .asyncTest provider.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions