-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add test for MTP test app with empty entry-point that doesn't handshake with dotnet test #50131
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: main
Are you sure you want to change the base?
Conversation
test/TestAssets/TestProjects/ConsoleAppDoesNothing/ConsoleAppDoesNothing.csproj
Outdated
Show resolved
Hide resolved
@Youssef1313 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
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.
@copilot Revert all changes under src
. Keep the tests only.
@Youssef1313 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
@copilot Revert all changes under |
@Youssef1313 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
f812c43
to
3a5d04d
Compare
3a5d04d
to
73d7c2e
Compare
The test is failing as I was expecting:
It will get fixed with #50134, hopefully. |
@Youssef1313 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
/azp run |
@Youssef1313 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Pull Request Overview
This PR adds test coverage for a new validation feature that prevents dotnet test
from silently succeeding when run against console applications that don't implement test frameworks or the Microsoft Testing Platform (MTP) protocol. The validation now returns an appropriate error message and exit code instead of silently succeeding.
- Adds a test case to verify that
dotnet test
properly fails with exit code 1 when run against a non-MTP console application - Creates a test asset representing a minimal console application that doesn't implement any testing framework
- Ensures proper error handling and user feedback for misuse of the
dotnet test
command
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
GivenDotnetTestRunsConsoleAppWithoutHandshake.cs | New test class that validates the error behavior when running dotnet test against non-test console apps |
dotnet.config | Configuration file specifying Microsoft Testing Platform as the test runner for the test asset |
Program.cs | Minimal console application that intentionally does nothing to simulate a non-test project |
ConsoleAppDoesNothing.csproj | Project file for the test asset with IsTestingPlatformApplication set to true |
test/TestAssets/TestProjects/ConsoleAppDoesNothing/ConsoleAppDoesNothing.csproj
Show resolved
Hide resolved
@Youssef1313 Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
When running
dotnet test
against console applications that don't implement test frameworks, the command would silently succeed with exit code 0, providing no feedback to users about why no tests were executed. This was confusing behavior that made it unclear whether the command worked correctly.Problem
Consider a simple console application:
Before this fix:
The command succeeded silently, giving no indication that the project wasn't actually a test project.
Solution
This PR adds MSBuild validation that detects when
dotnet test
is run against console applications (OutputType=Exe
) that are neither test projects (IsTestProject=true
) nor Microsoft Testing Platform applications (IsTestingPlatformApplication=true
).After this fix:
Changes
_ValidateTestProject
target inMicrosoft.NET.Sdk.targets
that validates console applications before test executionGenericFailure
) instead of 0 (Success
)GivenDotnetTestRunsConsoleAppWithoutHandshake
to verify the new behaviorThe validation works for both VSTest and Microsoft Testing Platform scenarios, ensuring consistent behavior across all test execution paths.
Fixes #49733.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.