-
Notifications
You must be signed in to change notification settings - Fork 275
Improve error message for all Assert.Contains.cs APIs #5793
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
…ment Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
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.
Please also fix the message for:
- overloads of
ContainsSingle
without predicate - overloads of
Contains
- overloads of
Contains
with predicate - all overloads of
DoesNotContain
…overloads Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
I've implemented improved error messages for all the requested assertion overloads in commit 614da6b:
All error messages are now specific and clearly explain what the assertion was checking, making debugging much easier for developers. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
I have increased scope of the ticket as I have noticed most of the Assert.Contains APIs were buggy (missing resx entry, wrong API name, ...) |
I've identified the bugs in the Assert.Contains APIs that need to be fixed:
I'll fix these issues systematically in the next commit. |
… docs Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.Contains.cs
Outdated
Show resolved
Hide resolved
The expanded scope has been addressed in commits 9767224 and 8f490a2. I've fixed the bugs in Assert.Contains APIs including wrong API names in error messages, incorrect parameter order, and incorrect XML documentation comments. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
# Conflicts: # src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt
src/TestFramework/TestFramework/Resources/FrameworkMessages.resx
Outdated
Show resolved
Hide resolved
src/TestFramework/TestFramework/Resources/FrameworkMessages.resx
Outdated
Show resolved
Hide resolved
- Change ContainsSingleMatchFailMsg to use "but found {1} item(s)" format - Change ContainsSingleFailMsg to use "but found {1} element(s)" format - Remove object values from ContainsItemFailMsg and DoesNotContainItemFailMsg - Update all corresponding test expectations - Update all xlf localization files Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
# Conflicts: # src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt
The error message for
ContainsSingle
with a predicate was confusing because it used the same generic message as the non-predicate version, suggesting the collection should have size 1 rather than explaining that exactly one item should match the predicate.Before:
This message is misleading because it suggests the entire collection should have size 1, when actually the assertion is checking that exactly one item matches the predicate
x % 2 == 0
.After:
The new message clearly explains that the assertion is looking for exactly one item that matches the predicate.
Changes made:
ContainsSingleMatchFailMsg
for predicate-specific error messagesThrowAssertSingleMatchFailed
method to handle predicate-specific errorsContainsSingle
to use the new error methodThis improvement makes debugging failed assertions much clearer for developers using predicate-based
ContainsSingle
calls.Fixes #5770.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
7tjvsblobprodcus341.vsblob.vsassets.io
dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)c78vsblobprodcus322.vsblob.vsassets.io
dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)cflvsblobprodcus383.vsblob.vsassets.io
/home/REDACTED/work/testfx/testfx/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/testfx/testfx/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/testfx/testfx/artifacts/toolset/10.0.0-beta.25313.2.txt
(dns block)dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)dotnet restore src/TestFramework/TestFramework/TestFramework.csproj --ignore-failed-sources
(dns block)d0svsblobprodcus381.vsblob.vsassets.io
dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)jd4vsblobprodcus366.vsblob.vsassets.io
dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)l49vsblobprodcus358.vsblob.vsassets.io
dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)uy6vsblobprodcus34.vsblob.vsassets.io
dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)vb4vsblobprodcus33.vsblob.vsassets.io
dotnet build src/TestFramework/TestFramework/TestFramework.csproj --configuration Debug
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 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.