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

TestContext (MSTEST0005) is enforced to be case-sensitive #4428

Closed
stan-sz opened this issue Dec 23, 2024 · 4 comments · Fixed by dotnet/docs#44061
Closed

TestContext (MSTEST0005) is enforced to be case-sensitive #4428

stan-sz opened this issue Dec 23, 2024 · 4 comments · Fixed by dotnet/docs#44061

Comments

@stan-sz
Copy link

stan-sz commented Dec 23, 2024

Describe the bug

With 3.7 release, the TestContext (MSTEST0005) is enforced to be case-sensitive. According to the docs, https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0005, it is meant to be case insensitive).

Steps To Reproduce

Create a test class with

public TestContext testContext { get; set; }

Expected behavior

No MSTEST0005

Actual behavior

MSTEST0005 is raised

@Youssef1313
Copy link
Member

Youssef1313 commented Dec 23, 2024

@stan-sz Thanks for reporting this.

Putting the analyzer behavior aside, is the testContext property actually set when it's named testContext and not TestContext?

I think the current analyzer behavior is correct and TestContext was probably never set when the name is testContext. But let me know if you see otherwise (preferably with a repro project).

If you confirm that TestContext isn't set when it's named testContext, we will update the analyzer docs as it would be currently incorrect.

@Evangelink
Copy link
Member

Just did a quick test and looks like this is a doc issue. @Youssef1313 please try to confirm with 3.2 or 3.3.

@Youssef1313
Copy link
Member

Youssef1313 commented Dec 23, 2024

@Evangelink I confirmed that 3.3 has the same behavior where the name must be exactly TestContext.

I opened a PR to increase our test coverage for this case, and opened a docs PR to fix the misleading information as well. Thanks again @stan-sz for bringing this to our attention.

@Youssef1313
Copy link
Member

I'm closing as the docs PR is merged, as well as the test coverage PR. @stan-sz Feel free to re-open and let us know if there are more issues on this topic. Thanks again for bringing it to our attention!

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

Successfully merging a pull request may close this issue.

3 participants