Skip to content

Commit cb7a0f9

Browse files
committed
Fixing .NET test IgnoreBrowserAttribute for NUnit 3
1 parent 0c680e7 commit cb7a0f9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

dotnet/test/common/CustomTestAttributes/IgnoreBrowserAttribute.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,24 @@ public string Reason
3636

3737
public void ApplyToTest(Test test)
3838
{
39-
if (test.RunState == RunState.Runnable)
39+
if (test.RunState != RunState.NotRunnable)
4040
{
4141
List<Attribute> ignoreAttributes = new List<Attribute>();
42-
IgnoreBrowserAttribute[] ignoreMethodAttributes = test.Method.GetCustomAttributes<IgnoreBrowserAttribute>(true);
43-
if (ignoreMethodAttributes.Length > 0)
42+
if (test.IsSuite)
4443
{
45-
ignoreAttributes.AddRange(ignoreMethodAttributes);
44+
Attribute[] ignoreClassAttributes = test.TypeInfo.GetCustomAttributes<IgnoreBrowserAttribute>(true);
45+
if (ignoreClassAttributes.Length > 0)
46+
{
47+
ignoreAttributes.AddRange(ignoreClassAttributes);
48+
}
4649
}
47-
48-
Attribute[] ignoreClassAttributes = test.TypeInfo.GetCustomAttributes<IgnoreBrowserAttribute>(true);
49-
if (ignoreClassAttributes.Length > 0)
50+
else
5051
{
51-
ignoreAttributes.AddRange(ignoreClassAttributes);
52+
IgnoreBrowserAttribute[] ignoreMethodAttributes = test.Method.GetCustomAttributes<IgnoreBrowserAttribute>(true);
53+
if (ignoreMethodAttributes.Length > 0)
54+
{
55+
ignoreAttributes.AddRange(ignoreMethodAttributes);
56+
}
5257
}
5358

5459
foreach (Attribute attr in ignoreAttributes)
@@ -63,6 +68,7 @@ public void ApplyToTest(Test test)
6368
}
6469

6570
test.RunState = RunState.Ignored;
71+
test.Properties.Set(PropertyNames.SkipReason, browserToIgnoreAttr.Reason);
6672
}
6773
}
6874
}

0 commit comments

Comments
 (0)