-
-
Notifications
You must be signed in to change notification settings - Fork 96
Description
I've been writing my own SkipAttribute that does not inherit from SkipAttribute but instead sets the SkipReason in the OnTestRegistered handler. I did this because SkipAttribute requires the skip reason to be provided in the constructor and I wanted more flexibility than a constant string.
For example, I'm writing tests that target embedded devices. The tests are largely device agnostic but sometimes a test needs to be skipped on certain devices. I'd like the skip reason to include the device name which I've been doing like so:
context.TestContext.SkipReason =
$"Skipping {context.TestDetails.TestName} as it is not supported by the current device '{deviceName}'.";With the new TestContext interface organization I can no longer do this as SkipReason on the ITestExecution interface is read-only. I'd switch to deriving from SkipAttribute but again SkipAttribute only allows setting the skip reason through the constructor.
Can SkipAttribute.Reason be updated so it can be set within derived SkipAttribute classes? By either making the Reason property set or protected set? This allows me more flexibility with the test skipping without needing to make a bunch of device-specific SkipAttributes.