Skip to content

TestCategory on class doesn't apply to inherited test methods #498

Description

Description

I have a test class that inherits test methods from a base test class, but I want to apply a TestCategory from the derived class in order to filter tests to run. The current implementation only looks at the TestCategory starting at the class that declares the test method, rather than the class being enumerated. But since TestCategory is inherited, I think it would make sense for it to include all categories starting at the class being enumerated.

I have a working implementation of this in a fork and am opening this issue to determine if the change is desired or if it's working as intended.

There's also a question about how assembly-level TestCategory attributes should work in this case. The code currently only considers the assembly containing the test method and not the assemblies containing the test class hierarchy. My fork changes it to only consider the assembly containing the test class being enumerated.

Steps to reproduce

[TestClass]
[TestCategory("base")]
public abstract class Base
{
    [TestMethod]
    public void TestSomeBaseInterfaceMethod() {}
}

[TestClass]
[TestCategory("derived")]
public class Derived : Base {}

Expected behavior

Derived.TestSomeBaseInterfaceMethod has both base and derived test categories:
image

Actual behavior

Derived.TestSomeBaseInterfaceMethod only has the base test category:
image

Environment

MSTest 1.3.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedUp for grabs; can be claimed by commenting.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions