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

Link to tool-specific documentation about adding test resource files #562

Open
JetForMe opened this issue Jul 21, 2024 · 3 comments
Open
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@JetForMe
Copy link

Description

As far as I can tell, the docs don't explain how one should add resources that might be needed for unit tests, like test data files.

Expected behavior

A section showing how where to add test resources

Actual behavior

No response

Steps to reproduce

No response

swift-testing version/commit hash

No response

Swift & OS version (output of swift --version && uname -a)

No response

@JetForMe JetForMe added the enhancement New feature or request label Jul 21, 2024
@stmontgomery
Copy link
Contributor

The instructions for how to do this depend on which tool you are using to build and run your Swift Testing tests. For example, when using a package you might use SwiftPM's instructions for adding resources, while an Xcode project uses a different workflow and runtime API.

If you're using an Xcode project, I'd encourage filing a Feedback with Apple with any documentation enhancement requests. But if you're using SwiftPM, does that documentation I linked above provide sufficient guidance?

We could still link to those tool-specific resources from the swift-testing docs, though. We can use this to track that.

@stmontgomery
Copy link
Contributor

(PRs are welcome on that front!)

@stmontgomery stmontgomery added the documentation Improvements or additions to documentation label Jul 21, 2024
@stmontgomery stmontgomery changed the title Need documentation for proper way to add testing resources Link to tool-specific documentation about adding test resource files Jul 21, 2024
@JetForMe
Copy link
Author

The instructions for how to do this depend on which tool you are using to build and run your Swift Testing tests.

Well, in this case, it's SPM, but I'm using Xcode to edit and run it. This issue was prompted by me reading somewhere that the PWD was set to the target root, and trying to build a path based on that. This is true when running tests from the command line (e.g.swift test), but not true when running tests from Xcode (it becomes /private/tmp). So I started researching how to properly add resources.

We could still link to those tool-specific resources from the swift-testing docs, though. We can use this to track that.

Yes, that would be great. A quick intro/summary of the steps, and a link. Something like “Testing resources are added like any other resource in your tool. For example, using SPM, do blah blah blah. See for more details. For Xcode, do …".

Eventually I discovered Bundle.module.load…, which works for both CLI and Xcode. Not sure that's the primary way to do it, but I think it’ll work across build environments and platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants