-
-
Notifications
You must be signed in to change notification settings - Fork 968
Update to MSTest 4 #1721
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
base: develop
Are you sure you want to change the base?
Update to MSTest 4 #1721
Conversation
replace Execute with ExecuteAsync and fix MSTEST0057 https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0057 (link currently dead)
Fixing this properly would require the tests to respect testContext.CancellationToken. I'm not sure this is worth fixing or how to even do it for the sync methods. https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0045
I assume that parallelization would break a lot of stuff. https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0001
|
I think it is a good time to merge this change |
Rob-Hague
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still suffers from missing console output in the integration tests #1693 (comment):
This branch:
develop:
I found microsoft/testfx#6457 but apparently it is working as intended...
To be fair, I don't see how they could solve this properly (and apparently it was broken in other ways before). How are you going to attach the logs to a specific test if the writing happens on a separate thread? As a workaround, we could use a custom logger that writes to the console synchronously, I pushed this in a separate branch here: mus65@043f18a . It works, but I'm not sure whether it's the right way to go. |
It does currently in fact write everything to one test, but normally if I want to see the stdout logs it's because I'm debugging a single test, so that's fine (I only just noticed it now)
That appears to do the trick. I had thought about something that writes to the test context (https://learn.microsoft.com/dotnet/api/microsoft.visualstudio.testtools.unittesting.testcontext.writeline) but I can't see it being any better. So I'd be fine with taking that. It would be nice if MSTest had some kind of M.E.L integration |


MSTest 4 has quite a few new asserts, analyzers and breaking changes, see https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-mstest-migration-v3-v4 .
Most of these were automatically fixed by the code fixer, see separate commits.
The update also triggered new sonar analyzer warnings, which seems to a bug in sonar, see SonarSource/sonar-dotnet#9767 . I suppressed these for now.