Skip to content

RetryAttribute to support decoration of class and/or assembly #7556

Description

@abatishchev

Summary

Currently, [RetryAttribute] doesn't support decoration of a class or an assembly. This feature request aim to overcome such a limitation.

Background and Motivation

Currently, the attribute is defined as of version 4.0.2:

[AttributeUsage(
    AttributeTargets.Method, AllowMultiple=false,
    Inherited=false)]
public sealed class RetryAttribute : RetryBaseAttribute

This results in a test method like this:

[TestClass]
public class MyEndToEndIntegrationTests
{
    [TestMethod, Retry(3)]
    public void TestA() {}

    [TestMethod, Retry(3)]
    public void TestB() {}

    [TestMethod, Retry(3)]
    public void TestC() {}
}

Proposed Feature

Instead, the attribute would be defined as this:

[AttributeUsage(
    AttributeTargets.Method | AttributeTargets.Class,
    AllowMultiple=false, Inherited=false)]
public sealed class RetryAttribute : RetryBaseAttribute

Or even this:

[AttributeUsage(
    AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly,
    AllowMultiple=false, Inherited=false)]
public sealed class RetryAttribute : RetryBaseAttribute

Resulting in a test class like this:

[TestClass, Retry(3)]
public class MyEndToEndIntegrationTests
{
    [TestMethod]
    public void TestA() {}

    [TestMethod]
    public void TestB() {}

    [TestMethod]
    public void TestC() {}
}

Or even this:

[assembly: Retry(3)]

Aspects to consider:

  • Can a test method override (make it smaller or greater) the value set at a higher level (class, assembly)? If yes, what would be the behavior (permit, ignore, throw)?

Alternative Designs

N/D

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mstestMSTest framework (not analyzers or assertions).
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions