Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

Please check the following before creating a Pull Request

  • If this is a new feature or piece of functionality, have you started a discussion and gotten agreement on it?
  • If it fixes a bug or problem, is there an issue to track it? If not, create one first and link it please so there's clear visibility.
  • Did you write tests to ensure you code works properly?

Description

The skipping documentation was missing coverage of Skip.Test(reason) and its variants for runtime test skipping.

Changes

Added comprehensive "Dynamic Skipping at Runtime" section to docs/docs/test-authoring/skip.md covering:

  • Skip.Test(reason) - Core method for dynamic skipping within test methods or hooks
  • Skip.When(condition, reason) - Conditional skip when condition is true
  • Skip.Unless(condition, reason) - Conditional skip unless condition is true
  • Hook integration - Examples of skipping from Before(Test) and Before(Class) hooks
  • Usage guidance - When to use dynamic skipping vs [Skip] attribute

Example

[Test]
public async Task MyTest()
{
    var apiAvailable = await CheckApiAvailability();
    
    if (!apiAvailable)
    {
        Skip.Test("API is not available");
    }
    
    await CallApi();
}

[Test]
public void ConditionalTest()
{
    var isCI = Environment.GetEnvironmentVariable("CI") != null;
    Skip.When(isCI, "This test doesn't run in CI environments");
    
    RunLocalOnlyTest();
}

Documentation builds successfully with no errors.

Original prompt

This section details on the original issue you should resolve

<issue_title>Skip.Test(reason) documentation</issue_title>
<issue_description>We need to update the skipping documentation to demonstrate how the static method Skip.Test(reason) can be used to skip tests dynamically.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update documentation for Skip.Test(reason) method Add Skip.Test() documentation for dynamic test skipping Dec 9, 2025
Copilot AI requested a review from thomhurst December 9, 2025 11:00
@thomhurst thomhurst marked this pull request as ready for review December 9, 2025 11:01
Copilot AI review requested due to automatic review settings December 9, 2025 11:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive documentation for dynamic test skipping at runtime using the Skip.Test() API and its variants (Skip.When(), Skip.Unless()), addressing a gap in the existing skip documentation.

Key Changes

  • Added a new "Dynamic Skipping at Runtime" section explaining when and how to use Skip.Test(reason) for runtime test skipping
  • Documented conditional skip helpers Skip.When() and Skip.Unless() with practical examples
  • Provided examples of using skip methods in test hooks (Before(Test) and Before(Class))

[Test]
public void Test1()
{
// This test will be skipped if database is unavailable
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).

Suggested change:

        // This test will be skipped if database is unavailable.
Suggested change
// This test will be skipped if database is unavailable
// This test will be skipped if database is unavailable.

Copilot uses AI. Check for mistakes.
[Test]
public void Test2()
{
// This test will also be skipped if database is unavailable
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).

Suggested change:

        // This test will also be skipped if database is unavailable.
Suggested change
// This test will also be skipped if database is unavailable
// This test will also be skipped if database is unavailable.

Copilot uses AI. Check for mistakes.
[Test]
public void Test1()
{
// All tests in this class will be skipped if service is unavailable
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).

Suggested change:

        // All tests in this class will be skipped if service is unavailable.
Suggested change
// All tests in this class will be skipped if service is unavailable
// All tests in this class will be skipped if service is unavailable.

Copilot uses AI. Check for mistakes.

Skip.When(isCI, "This test doesn't run in CI environments");

// Test continues only when not in CI
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).

Suggested change:

        // Test continues only when not in CI.
Suggested change
// Test continues only when not in CI
// Test continues only when not in CI.

Copilot uses AI. Check for mistakes.

Skip.Unless(hasRequiredPermissions, "User doesn't have required permissions");

// Test continues only if user has permissions
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Inconsistent punctuation in comment. The comment should end with a period for consistency with other comments in the documentation (e.g., line 93, 172, 206).

Suggested change:

        // Test continues only if user has permissions.
Suggested change
// Test continues only if user has permissions
// Test continues only if user has permissions.

Copilot uses AI. Check for mistakes.
This was referenced Dec 15, 2025
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.

Skip.Test(reason) documentation

2 participants