docs: Add documentation for TestContext.Parameters - #6558
Conversation
Adds a new documentation page explaining the --test-parameter command-line option and TestContext.Parameters dictionary. Includes usage examples for environment configuration, conditional test logic, and passing secrets. Also adds a cross-reference from the TestContext documentation page. Closes #6553 Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Greptile SummaryAdds documentation for passing and consuming
Confidence Score: 3/5The PR should not merge until the truncated-value guidance and non-compiling skip examples are corrected. The documented connection-string invocation loses most of its value under the current parser, and both conditional examples fail to compile against TUnit's public skipping API. Files Needing Attention: docs/docs/execution/parameters.md
|
| Filename | Overview |
|---|---|
| docs/docs/execution/parameters.md | Adds the main parameter guide, but its connection-string parsing claim is incompatible with the current parser and two examples call nonexistent Assert.Skip. |
| docs/docs/writing-tests/test-context.md | Adds an accurate introductory example and cross-reference to the new parameter guide. |
| docs/sidebars.ts | Adds the new execution page to the Running Tests sidebar using the correct document identifier. |
Reviews (1): Last reviewed commit: "docs: address review feedback - use TryG..." | Re-trigger Greptile
| ## Notes | ||
|
|
||
| - Parameters are available for the entire test session — they are not scoped to individual tests. | ||
| - The parameter format must be `KEY=VALUE`. Values containing `=` characters are supported (only the first `=` is used as the delimiter). |
There was a problem hiding this comment.
Equals signs truncate parameter values
When a value contains additional = characters, the current parser stores only the segment immediately after the first delimiter, so the documented connection string becomes Server and the database connection fails. The example and note should reflect the parser's actual limitation or accompany a parser fix that preserves the complete value.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| { | ||
| if (!TestContext.Parameters.ContainsKey("run-integration")) | ||
| { | ||
| Assert.Skip("Integration tests require --test-parameter run-integration=true"); |
There was a problem hiding this comment.
Skip examples use nonexistent API
When either conditional-skipping example is copied into a current TUnit project, Assert.Skip cannot compile because Assert has no Skip member; TUnit's supported runtime API is Skip.Test. The same invalid call also occurs in the connection-string example on line 86.
Knowledge Base Used: Benchmarks and the Docusaurus Docs Site
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e0b3f5a63
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { | ||
| if (!TestContext.Parameters.ContainsKey("run-integration")) | ||
| { | ||
| Assert.Skip("Integration tests require --test-parameter run-integration=true"); |
There was a problem hiding this comment.
Use the TUnit skip API in the examples
When users copy either conditional-skip example, it will not compile because TUnit has no Assert.Skip method; runtime skipping is exposed as Skip.Test(reason) in src/TUnit.Core/Skip.cs. Update both occurrences so the documented integration and database patterns are usable.
Useful? React with 👍 / 👎.
| ## Notes | ||
|
|
||
| - Parameters are available for the entire test session — they are not scoped to individual tests. | ||
| - The parameter format must be `KEY=VALUE`. Values containing `=` characters are supported (only the first `=` is used as the delimiter). |
There was a problem hiding this comment.
Remove or implement support for additional equals signs
For a value such as token=abc=def, the engine currently calls parameter.Split('=') and stores only split[1] in TUnitProcessInitializer.ParseTestParameters, producing abc rather than abc=def. This note therefore promises behavior the CLI does not provide; either limit the split to two parts in the parser or document the restriction.
Useful? React with 👍 / 👎.
TestContext.Parameters(passed via--test-parameter KEY=VALUE) has existed for ~2 years with no documentation.Changes:
docs/docs/execution/parameters.mdcovering CLI usage, accessing parameters in tests, and common patterns (environment config, conditional skipping, connection strings)Usage:
TestContext.Parameters#6553