ArgumentParser and XCTest

What is the proper means to run tests on a project using ArgumentParser? I made a new project using the “Command Line Tool” template and added the ArgumentParser as a dependency (File>Swift Packages>Add Package Dependency…). I created a new test target and added the relevant source files (could set the command line tool as the host application). However I was still getting undefined symbol errors from ArgumentParser code, and couldn’t find a way to link the package to the test target. Is it possible to test a command line tool with a dependency on ArgumentParser (or any Swift package added in the same way) in Xcode? Is there some other way, maybe swift test?

As far as I can tell, XCTest isn't very useful with CLI executable targets.

I have added testing of my tool's command line by putting its ParsableCommand struct in its own module, and then I can test that with XCTest (and swift test.) That way I can test the validate() function with a variety of command lines, quickly.

Terms of Service

Privacy Policy

Cookie Policy