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

Warning "TestClass attribute defined on generic non-abstract class" cannot be disabled/ignored #2723

Open
nietras opened this issue Apr 17, 2024 · 2 comments
Assignees
Milestone

Comments

@nietras
Copy link

nietras commented Apr 17, 2024

Describe the bug

Running MSTest on attached project causes warning. This we have observed for a long time previously (e.g. 3.2.2) this was UTA001. Using MSTest 3.3.1 and now the below warning occurs.

[MSTest][Discovery][C:\git\issues\MSTestUTA001\Reproduction.Settings.Test\bin\Debug\net8.0\Reproduction.Settings.Test.dll] 
TestClass attribute defined on generic non-abstract class Reproduction.Settings.Test.ProjectSettingsTestBase`1

While this warning is fine, it is not possible to disable it, which we would like.

Steps To Reproduce

  1. Download MSTestUTA001.zip
  2. Extract somewhere
  3. Run dotnet test
  4. See warning

Expected behavior

Possibility to disable the warning and hence avoid it.

Actual behavior

Warning.

I understand the coding pattern is perhaps a bit unusual but it allows us to reuse tests across many different types, without having to rewrite TestMethod stuff, so unless this can be done similarly we would like to disable the warning. Preferable for the specific types.

AB#2050329

@Evangelink
Copy link
Member

Hi @nietras! Thanks for the bug report and the cool repro!

I have done a quick investigation of the issue and I think there is a relatively big problem with the type cache on MSTest. Indeed, the cache is retrieving attributes using inheritance and although the validation method asks for non-inherited attributes, because of the cache, we retrieve inherited and so we end up reporting.

@Evangelink Evangelink added this to the 3.5.0 milestone Apr 23, 2024
@testplatform-bot
Copy link
Contributor

✅ Successfully linked to Azure Boards work item(s):

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

No branches or pull requests

3 participants