Skip to content

Fix documentation: Update TestContext API from context.Result to context.Execution.Result - #3837

Merged
thomhurst merged 2 commits into
mainfrom
copilot/fix-test-context-status-check
Nov 13, 2025
Merged

Fix documentation: Update TestContext API from context.Result to context.Execution.Result#3837
thomhurst merged 2 commits into
mainfrom
copilot/fix-test-context-status-check

Conversation

CopilotAI commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Documentation used the deprecated direct context.Result property access instead of the current context.Execution.Result API, and incorrectly referenced TestStatus enum instead of TestState.

Changes

Updated four documentation files to use the correct API:

Before:

if(context.Result?.Status==TestStatus.Failed){awaitCaptureScreenshot(cancellationToken);}

After:

if(context.Execution.Result?.State==TestState.Failed){awaitCaptureScreenshot(cancellationToken);}

Files Modified

  • docs/docs/test-lifecycle/cleanup.md - After hook example
  • docs/docs/advanced/test-variants.md - Property-based testing shrinking pattern
  • docs/docs/advanced/extension-points.md - Event receiver examples (2 locations)
  • docs/docs/advanced/performance-best-practices.md - Test metrics tracking example

All documentation now correctly accesses test results via the ITestExecution interface as context.Execution.Result?.State.

Original prompt

This section details on the original issue you should resolve

<issue_title>Documentation: TestContext.Result?.Status == TestStatus.Failed should be context.Execution.Result?.State == TestState.Failed?</issue_title>
<issue_description>https://tunit.dev/docs/test-lifecycle/cleanup

Before

[After(Test)]publicasyncTaskCleanup(TestContextcontext,CancellationTokencancellationToken){// Access test results via contextif(context.Result?.Status==TestStatus.Failed){awaitCaptureScreenshot(cancellationToken);}}

After

[After(Test)]publicasyncTaskCleanup(TestContextcontext,CancellationTokencancellationToken){// Access test results via contextif(context.Execution.Result?.State==TestState.Failed){awaitCaptureScreenshot(cancellationToken);}}
```</issue_description>
## Commentson the Issue (youare @copilot inthissection)<comments></comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ult to context.Execution.Result
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
CopilotAI changed the title [WIP] Fix test context result status check in cleanup methodFix documentation: Update TestContext API from context.Result to context.Execution.ResultNov 13, 2025
CopilotAI requested a review from thomhurstNovember 13, 2025 19:29
@thomhurst
thomhurst marked this pull request as ready for review November 13, 2025 19:30
@thomhurst
thomhurst merged commit 6328812 into mainNov 13, 2025
5 checks passed
@thomhurst
thomhurst deleted the copilot/fix-test-context-status-check branch November 13, 2025 19:30
@suugbut

Copy link
Copy Markdown

https://tunit.dev/docs/test-lifecycle/test-context

if(TestContext.Current?.Result?.State==TestState.Failed){// Take a screenshot?}

should be

if(TestContext.Current?.Execution.Result?.State==TestState.Failed){// Take a screenshot?}

Sign up for freeto 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.

Documentation: TestContext.Result?.Status == TestStatus.Failed should be context.Execution.Result?.State == TestState.Failed?

3 participants

@suugbut@thomhurst