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

TestPropertyAttribute doesn't correctly consider the test class and only considers the "declaring type" #5249

Closed
Youssef1313 opened this issue Mar 17, 2025 · 1 comment · Fixed by #5293
Assignees
Labels

Comments

@Youssef1313
Copy link
Member

Youssef1313 commented Mar 17, 2025

if (testMethodInfo.TestMethod.DeclaringType is { } testClass)

This logic is incorrect. testMethodInfo.TestMethod.DeclaringType isn't necessarily the same as testMethodInfo.Parent.ClassType.

The correct one should be testMethodInfo.Parent.ClassType.

This affects the case where there a TestMethod is declared in abstract class, and the derived test class has TestProperty attribute. In that case, the property doesn't correctly flow to TestContext.Properties. In this case, the DeclaringType is the abstract class, while the ClassType is really the concrete test class.

@Youssef1313
Copy link
Member Author

I think it's a small enough of change that we can include in 3.8.4

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

Successfully merging a pull request may close this issue.

1 participant