Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ArgumentParserTestHelpers #491

Open
MartinP7r opened this issue Sep 17, 2022 · 6 comments
Open

Expose ArgumentParserTestHelpers #491

MartinP7r opened this issue Sep 17, 2022 · 6 comments

Comments

@MartinP7r
Copy link
Contributor

MartinP7r commented Sep 17, 2022

Sorry if this is a very naive question or what I'm trying to do is already possible with the current package setup.

I find the ArgumentParserTestHelpers target very helpful and it would be great to be able to add it as a dependency for the client's testTarget.

As a test, I tried to simply add a product target for it in a fork.


Note
below error was solved by @KS1019's suggestion

However, I keep getting the following error:

product 'ArgumentParserTestHelpers' required by package 'MyApp' target 'MayAppTests' not found in package 'swift-argument-parser'.

(Here is a sample reproducing this error)


Best regards,
Martin

@MartinP7r MartinP7r changed the title Use TestHelpers from consuming testTarget Use TestHelpers from client's testTarget Sep 20, 2022
@KS1019
Copy link
Contributor

KS1019 commented Sep 26, 2022

My understanding is that it is not possible with the current setup of this project.

There have been similar issues from time to time like this one #255. I remember seeing @natecook1000 commenting they're not doing it because they cannot promise it will be maintained appropriately (but I couldn't find that particular issue so I'm not sure).

On the other hand, #255 is labeled as enhancement so maybe they are thinking of doing this.

cc @natecook1000 @rauhul Any clarification is much appreciated!

@MartinP7r
Copy link
Contributor Author

MartinP7r commented Sep 26, 2022

@KS1019 thank you for the details!

commenting they're not doing it because they cannot promise it will be maintained appropriately

I think I found this issue here: #303

Understood, I agree that guaranteeing maintainability is not really high priority for test helpers.
If it's something worthwhile, I'd love to help out in whatever capacity I can here.
However I seem to still fail at the basic understanding of why my sample is not finding the product even if I declare it in Package.swift. 😓

@KS1019
Copy link
Contributor

KS1019 commented Sep 26, 2022

@MartinP7r I'm not too sure but you might want to modify Package@swift-5.6.swift too.

@MartinP7r
Copy link
Contributor Author

MartinP7r commented Sep 26, 2022

@MartinP7r I'm not too sure but you might want to modify Package@swift-5.6.swift too.

Oh, wow. Thanks so much.
I didn't know there's a way to specify a Package.swift for different swift versions. (If that's what's happening here)

@MartinP7r MartinP7r changed the title Use TestHelpers from client's testTarget Expose ArgumentParserTestHelpers Sep 28, 2022
@natecook1000
Copy link
Member

👋🏻 We're definitely open to making ArgumentParserTestHelpers an exported target, but it really needs an API review before we're ready to do that, as it's mostly grown organically to support the specific kinds of tests that the library needs.

@MartinP7r, what parts are you finding useful?

@MartinP7r
Copy link
Contributor Author

Thank you for your time @natecook1000 👋🏼

AssertExecuteCommand is very useful.
I think the way you test the examples would naturally fit most apps that depend on ArgumentParser because integration testing is most practical for CLI tools of average size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants