-
Notifications
You must be signed in to change notification settings - Fork 293
chore: migrate from TimeoutAttribute to CancelAfterAttribute #3119
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
chore: migrate from TimeoutAttribute to CancelAfterAttribute #3119
Conversation
5ed9631 to
dbbc139
Compare
|
|
||
| using System.Runtime.InteropServices; | ||
|
|
||
| [assembly: NUnit.Framework.Timeout(Microsoft.Playwright.Tests.TestConstants.DefaultTestTimeout)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First line removed, second line moved to the PlaywrightTestAttribute.cs.
|
|
||
|
|
||
| [PlaywrightTest("screencast.spec.ts", "video.path()/saveAs() does not hang immediately after launchPersistentContext and context.close()")] | ||
| [CancelAfter(30_000)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
30 is the default, hence removed.
dbbc139 to
3cf89e5
Compare
| /// <param name="fileName"><see cref="FileName"/></param> | ||
| /// <param name="describe"><see cref="Describe"/></param> | ||
| /// <param name="nameOfTest"><see cref="TestName"/></param> | ||
| public PlaywrightTestAttribute(string fileName, string describe, string nameOfTest) : this(fileName, nameOfTest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method with this kind of signature we haven't used much, hence removed + modified the tests which used it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR migrates internal tests from using the TimeoutAttribute to the new CancelAfterAttribute, addressing test timeout handling and removing obsolete attributes. Key changes include:
- Adding CancelAfterAttribute usage and corresponding interface implementations in PlaywrightTestAttribute.
- Updating tests to use CancelAfter with appropriate timeout constants.
- Removing legacy timeout and parallelization assembly attributes.
Reviewed Changes
| File | Description |
|---|---|
| src/Playwright.Tests/Attributes/PlaywrightTestAttribute.cs | Extended attribute to implement additional contexts and to apply CancelAfter for timing out tests. |
| src/Playwright.Tests/PageDispatchEventTests.cs | Updated PlaywrightTest attribute usage by removing redundant parameters. |
| src/Playwright.Tests/PageWaitForNavigationTests.cs | Replaced direct timeout values with TestConstants and removed one CancelAfter attribute. |
| src/Playwright.Tests/ElementHandleConvenienceTests.cs | Updated PlaywrightTest attribute usage by removing an extra parameter. |
| src/Playwright.Tests/TestConstants.cs | Removed assembly-level attributes to align with the new timeout handling approach. |
| src/Playwright.Tests/PageEvaluateTests.cs | Removed inline description from PlaywrightTest in favor of a code comment. |
| src/Playwright.Tests/ScreencastTests.cs | Removed the CancelAfter attribute to streamline test timeout configuration. |
| src/Playwright.Tests/BrowserContextBasicTests.cs | Updated PlaywrightTest attributes to omit redundant descriptions. |
| src/Playwright.Tests/PageNetworkRequestTest.cs | Updated the PlaywrightTest attribute usage for clarity and consistency. |
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/Playwright.Tests/PageWaitForNavigationTests.cs:317
- The removal of the CancelAfter attribute on this test might lead to unintended behavior if a test-specific timeout is expected. Please confirm that the omission of a CancelAfter configuration is intentional to avoid potential flakiness.
public async Task ShouldTakeTimeoutIntoAccount()
This only affects our internal tests.
Fixes #3118