Skip to content

docs: Add documentation for TestContext.Parameters - #6558

Merged
thomhurst merged 3 commits into
mainfrom
copilot/add-documentation-for-testcontext-parameters
Aug 7, 2026
Merged

docs: Add documentation for TestContext.Parameters#6558
thomhurst merged 3 commits into
mainfrom
copilot/add-documentation-for-testcontext-parameters

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

TestContext.Parameters (passed via --test-parameter KEY=VALUE) has existed for ~2 years with no documentation.

Changes:

  • New doc page docs/docs/execution/parameters.md covering CLI usage, accessing parameters in tests, and common patterns (environment config, conditional skipping, connection strings)
  • Added sidebar entry under "Running Tests"
  • Added cross-reference from the existing TestContext doc page

Usage:

dotnet run --test-parameter environment=staging --test-parameter browser=chrome
if (TestContext.Parameters.TryGetValue("environment", out var values))
{
    var environment = values.First(); // "staging"
}

Copilot AI linked an issue Aug 7, 2026 that may be closed by this pull request
1 task
Copilot AI and others added 2 commits August 7, 2026 10:09
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>
Copilot AI changed the title [WIP] Add documentation for TestContext.Parameters docs: Add documentation for TestContext.Parameters Aug 7, 2026
Copilot AI requested a review from thomhurst August 7, 2026 10:10
@thomhurst
thomhurst marked this pull request as ready for review August 7, 2026 10:19
@thomhurst
thomhurst merged commit a4afa48 into main Aug 7, 2026
4 checks passed
@thomhurst
thomhurst deleted the copilot/add-documentation-for-testcontext-parameters branch August 7, 2026 10:19
@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown

Greptile Summary

Adds documentation for passing and consuming TestContext.Parameters, links it from the existing Test Context guide, and exposes the page in the Running Tests sidebar. The new guide currently misdocuments equals-sign handling and contains two examples using a nonexistent skipping API.

  • Documents repeated --test-parameter KEY=VALUE arguments and common usage patterns.
  • Adds a Test Parameters section to the Test Context guide.
  • Registers the new page in the Docusaurus sidebar.

Confidence Score: 3/5

The 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

Important Files Changed

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).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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

Successfully merging this pull request may close these issues.

[Docs]: Add documentation for TestContext.Parameters

2 participants