Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestClassAttribute inheritance is inconsistent #4278

Closed
Youssef1313 opened this issue Dec 8, 2024 · 5 comments · Fixed by #4318
Closed

TestClassAttribute inheritance is inconsistent #4278

Youssef1313 opened this issue Dec 8, 2024 · 5 comments · Fixed by #4318
Assignees
Labels

Comments

@Youssef1313
Copy link
Member

Youssef1313 commented Dec 8, 2024

namespace TestProject9;

[TestClass]
public class Test1
{
    [TestMethod]
    public void TestMethod1()
    {
        // Called. Correct behavior.
    }
}

public class Test2 : Test1
{
    [AssemblyInitialize]
    public static void AsmInit2(TestContext _)
    {
        // Called. Unexpected behavior.
    }

    [ClassInitialize]
    public static void ClassInit2(TestContext testContext)
    {
        // Not Called. Correct behavior.
    }

    [TestMethod]
    public void TestMethod2()
    {
        // Not called. Correct behavior
    }
}

Root cause seems to be:

if (!_reflectionHelper.IsDerivedAttributeDefined<TestClassAttribute>(t, inherit: true))

@Evangelink
Copy link
Member

These bugs of derived vs non derived are endless..

@Youssef1313
Copy link
Member Author

@Evangelink Willing to take a break here to fix this in minor version or should it be v4?

@Evangelink
Copy link
Member

Sounds like a bug in the wanted/documented/expected behavior so I am fine to fix it.

PS: I think the ticket title should be "inconsistent".

@Youssef1313 Youssef1313 changed the title TestClassAttribute inheritance is consistent TestClassAttribute inheritance is inconsistent Dec 9, 2024
@Youssef1313
Copy link
Member Author

PS: I think the ticket title should be "inconsistent".

Yup! Fixed the title.

@Youssef1313 Youssef1313 self-assigned this Dec 9, 2024
@Youssef1313 Youssef1313 added this to the MSTest 3.8 / Platform 1.6 milestone Dec 9, 2024
@Youssef1313
Copy link
Member Author

@Evangelink I added to 3.8 milestone. Feel free to move/remove accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants