2828
2929// Run all tests in sequence
3030[ assembly: LevelOfParallelism ( 1 ) ]
31+ [ assembly: Parallelizable ( ParallelScope . Fixtures ) ]
3132
3233namespace Microsoft . Playwright . Tests ;
3334
3435/// <summary>
3536/// Enables decorating test facts with information about the corresponding test in the upstream repository.
3637/// </summary>
3738[ AttributeUsage ( AttributeTargets . Method , AllowMultiple = true ) ]
38- public class PlaywrightTestAttribute : TestAttribute , IWrapSetUpTearDown
39+ public class PlaywrightTestAttribute : TestAttribute , IApplyToContext , IApplyToTest , IWrapSetUpTearDown
3940{
41+ private readonly CancelAfterAttribute _cancelAfterAttribute = new ( TestConstants . DefaultTestTimeout ) ;
42+
4043 public PlaywrightTestAttribute ( )
4144 {
4245 }
@@ -52,17 +55,6 @@ public PlaywrightTestAttribute(string fileName, string nameOfTest)
5255 TestName = nameOfTest ;
5356 }
5457
55- /// <summary>
56- /// Creates a new instance of the attribute.
57- /// </summary>
58- /// <param name="fileName"><see cref="FileName"/></param>
59- /// <param name="describe"><see cref="Describe"/></param>
60- /// <param name="nameOfTest"><see cref="TestName"/></param>
61- public PlaywrightTestAttribute ( string fileName , string describe , string nameOfTest ) : this ( fileName , nameOfTest )
62- {
63- Describe = describe ;
64- }
65-
6658 /// <summary>
6759 /// The file name origin of the test.
6860 /// </summary>
@@ -83,6 +75,22 @@ public PlaywrightTestAttribute(string fileName, string describe, string nameOfTe
8375 /// </summary>
8476 public string Describe { get ; }
8577
78+ public void ApplyToContext ( TestExecutionContext context )
79+ {
80+ if ( context . TestCaseTimeout == 0 )
81+ {
82+ ( _cancelAfterAttribute as IApplyToContext ) . ApplyToContext ( context ) ;
83+ }
84+ }
85+
86+ public new void ApplyToTest ( Test test )
87+ {
88+ base . ApplyToTest ( test ) ;
89+ if ( TestExecutionContext . CurrentContext . TestCaseTimeout == 0 )
90+ {
91+ _cancelAfterAttribute . ApplyToTest ( test ) ;
92+ }
93+ }
8694 /// <summary>
8795 /// Wraps the current test command in a <see cref="UnobservedTaskExceptionCommand"/>.
8896 /// </summary>
0 commit comments