Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

A project to demonstrate how to unit test a struct with ArgumentParser and SwiftPackageManager

Notifications You must be signed in to change notification settings

igorcferreira/ArgumentParserUnitTestSample

Repository files navigation

ArgumentParser Unit Test Sample

This project demonstrate how a struct that conforms to ParsableCommand can be unit tested with the support of the .parse(_:[String]) method, an output variable and CodingKeys.

The goal is to demonstrate a code pattern that allows to code injection and an unit test simiar to:

func testDefaultPrefix() throws {
    let runner = try PrintMessage.parse(["Test Message"]) {
        XCTAssertEqual($0, "Message: Test Message", "Invalid message option")
    }
    try runner.run()
}

About

A project to demonstrate how to unit test a struct with ArgumentParser and SwiftPackageManager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages