Swiftpack.co -  Appsaurus/VaporTestUtils as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Appsaurus/VaporTestUtils
Basic test utils to make testing Vapor apps a little simpler.
.package(url: "https://github.com/Appsaurus/VaporTestUtils.git", from: "0.1.3")

VaporTestUtils

Swift Vapor Swift Package Manager License

Installation

VaporTestUtils is available through Swift Package Manager. To install, simply add the following line to the dependencies in your Package.swift file.

let package = Package(
    name: "YourProject",
    dependencies: [
        ...
        .package(url: "https://github.com/Appsaurus/VaporTestUtils", from: "1.0.0"),
    ],
    targets: [
      .testTarget(name: "YourApp", dependencies: ["VaporTestUtils", ... ])
    ]
)
        

Usage

Check the app included in this project for a complete example. Here are some of the basics:

1. Import the library

import VaporTestUtils

2. Setup your test case

Create a test case inheriting from VaporTestCase. Override computed properties booter and configurer and return the corresponding boot and configure functions from your app. Then, just start executing requests. Pretty simple stuff.

final class ExampleAppTests: VaporTestCase {

	static var allTests = [
		("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests),
		("testMyApp", testMyApp)
	]

	func testLinuxTestSuiteIncludesAllTests(){
		assertLinuxTestCoverage(tests: type(of: self).allTests)
	}

	override var booter: AppBooter{
		return ExampleApp.boot
	}
	
	override var configurer: AppConfigurer{
		return ExampleApp.configure
	}
	
	override func setUp() {
		super.setUp()
		loggingLevel = .debug //This is optional. Logs all requests and responses to the console.
	}

	func testMyApp() throws {
		let response = try executeRequest(method: .GET, path: "testing-vapor-apps")
		XCTAssert(response.has(statusCode: .ok))
		XCTAssert(response.has(content: "is super easy"))
	}
}

Acknowledgements

Some extension methods were blatantly borrowed from LiveUI's VaporTestTools. You should also check their library out as it serves a similar purpose (and might be even better).

Contributing

We would love you to contribute to VaporTestUtils, check the CONTRIBUTING file for more info.

License

VaporTestUtils is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 0
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics