Skip to content

Allow overriding / setting of SkipAttribute.Reason #3607

@lizalc

Description

@lizalc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions