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

Tests targeting net472 are not run if the tests are launched from Visual Studio #4487

Closed
DaveTryon opened this issue Dec 31, 2024 · 1 comment

Comments

@DaveTryon
Copy link

Describe the bug

Our project targets both .NET 8 and .NET Framework 4.7.2. We use Visual Studio (current version 17.12.1) as our IDE. When using release 3.6.4 of MSTest.TestFramework and MSTest.TestAdapter, the tests for both targets are detected and run from within Visual Studio. When we upgrade to release 3.7.0 of MSTest.TestFramework and MSTest.TestAdapter, the .NET Framework 4.7.2 targeted tests appear in the Visual Studio test explorer, but the tests are ignored if the tests are launched inside Visual Studio. All tests run as expected if tests are run from the command line. Here's a table describing the behavior, in case that's clearer:

MSTest.Test* version Targeted framework Launch from Visual Studio Launch via dotnet test
3.6.4 net472 Tests run Tests run
3.6.4 net80 Tests run Tests run
3.7.0 net472 Tests are ignored Tests run
3.7.0 net80 Tests run Tests run

Steps To Reproduce

This is happening in the https://github.com/microsoft/sbom-tool project, but I'm including a stripped down demo as Sample.zip to simplify the repro.

Using release 3.6.4 of MSTest.Test*

  1. Expand the Zip file to a clean local folder
  2. Open Sample.sln in visual studio
  3. From the menu, Tests > Run All Tests
  4. After the tests run, the status bar will report "Test run finished: 2 Tests (2 Passed, 0 Failed, 0 Skipped)'
  5. Exit visual studio
  6. Execute dotnet test from the command prompt
  7. Tests will run, with a summary saying "Test Summary: total: 2, failed: 0, succeeded: 2, skipped: 0"

Using release 3.7.0 of MSTest.Test*

  1. Expand the Zip file to a clean local folder
  2. Open Directory.Packages.props in a text editor
  3. Bump MSTest.TestAdapter (line 13) and MSTest.TestFramework (line 14) from version 3.6.4 to version 3.7.0
  4. Save the file
  5. Open Sample.sln in visual studio
  6. From the menu, Tests > Run All Tests
  7. After the tests run, the status bar will report "Test run finished: 1 Tests (1 Passed, 0 Failed, 0 Skipped). This difference from 3.6.4 is the bug being reported
  8. Exit visual studio
  9. Execute dotnet test from the command prompt
  10. Tests will run, with a summary saying "Test Summary: total: 2, failed: 0, succeeded: 2, skipped: 0"

Expected behavior

Tests targeting both net472 and net80 should be detected and run from within Visual Studio

Actual behavior

Tests targeting net80 get detected and run from within Visual Studio, while the tests targeting net472 are ignored from within Visual Studio

Additional context

@Youssef1313
Copy link
Member

Thanks for the detailed report and for extracting a small repro. This is a duplicate of #4426 so I'm going to close as a duplicate. As we are in a holiday season, we may not be able to look before the next week. Sorry for the inconvenience.

FYI @Evangelink, this repro here doesn't seem to be using MTP, which is curious.

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

No branches or pull requests

2 participants