Skip to content

Expand parameterized testing documentation to mention try/await support and showcase helper pattern #1133

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

Merged

Conversation

stmontgomery
Copy link
Contributor

This expands a few places where we document parameterized testing APIs to mention try/await support and showcase a common pattern for sharing arguments between multiple tests.

Modifications:

  • For each @Test macro which accepts arguments, mention that try and await are supported and that arguments are lazily evaluated.
  • In the "Implementing parameterized tests" article, add a new section titled "Pass the same arguments to multiple test functions" showcasing the pattern of extracting common arguments to a separate property.
  • Add a > Tip: callout within that new article section mentioning try/await support.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

Fixes rdar://130929060

…rt and showcase helper pattern

Fixes rdar://130929060
@stmontgomery stmontgomery added this to the Swift 6.x milestone May 28, 2025
@stmontgomery stmontgomery self-assigned this May 28, 2025
@stmontgomery stmontgomery added the documentation 📚 Improvements or additions to documentation label May 28, 2025
@stmontgomery stmontgomery added enhancement New feature or request parameterized-testing Related to parameterized testing functionality macros 🔭 Related to Swift macros such as @Test or #expect labels May 28, 2025
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@iamleeg iamleeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful guidance, thank you! I've suggested changing from passive to active voice throughout, and provided an example of what I mean.

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@@ -217,8 +217,10 @@ public macro Test<C>(
/// - collection: A collection of values to pass to the associated test
/// function.
///
/// During testing, the associated test function is called once for each element
/// in `collection`.
/// You can prefix the expression you pass to `collection` with `try` or `await`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly here, but do we need to repeat this for each overload or can we just document it in the article?

}
```

> Tip: You can prefix expressions passed to `arguments:` with `try` or `await`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use tips otherwise in our documentation? I don't mind starting to use them, but I would like to get guidelines for when to use them instead of other callouts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamleeg Any advice?

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery stmontgomery merged commit d611120 into swiftlang:main May 30, 2025
3 checks passed
@stmontgomery stmontgomery deleted the effectful-arguments-documentation branch May 30, 2025 19:33
@stmontgomery stmontgomery modified the milestones: Swift 6.x, Swift 6.2 Jun 7, 2025
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 macros 🔭 Related to Swift macros such as @Test or #expect parameterized-testing Related to parameterized testing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants