Skip to content

Conversation

@mus65
Copy link
Contributor

@mus65 mus65 commented Oct 25, 2025

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.

@WojciechNagorski
Copy link
Collaborator

I think it is a good time to merge this change

Copy link
Collaborator

@Rob-Hague Rob-Hague left a 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:

Image

develop:

Image

I found microsoft/testfx#6457 but apparently it is working as intended...

@mus65
Copy link
Contributor Author

mus65 commented Nov 1, 2025

It still suffers from missing console output in the integration tests #1693 (comment):

This branch:

Image develop: Image I found [microsoft/testfx#6457](https://github.com/microsoft/testfx/issues/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.

@Rob-Hague
Copy link
Collaborator

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?

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)

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.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants