-
Notifications
You must be signed in to change notification settings - Fork 278
Add TestCategories property to ITestDataRow for per-test-case categorization #5795
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
Co-authored-by: Evangelink <[email protected]>
…ng categories Co-authored-by: Evangelink <[email protected]>
…feature Co-authored-by: Evangelink <[email protected]>
TestCategories
to ITestDataRow
…analyzer error Co-authored-by: Youssef1313 <[email protected]>
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:
|
@copilot There is a merge conflict. Can you fix it? |
src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt
Outdated
Show resolved
Hide resolved
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:
|
/// Gets or sets the test categories for the test case. | ||
/// </summary> | ||
[DataMember] | ||
public IList<string>? TestCategories { get; set; } |
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.
@Youssef1313 what about using a readonly collection here? We don't really expect to modify the collection from our end. The benefit of keeping it this way is to allow users to create the TestDataRow
instance and add categories after but the logic could be reverted.
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.
I kept IList<string>?
to maintain the common initialization pattern where users create a List<string>
and assign it to TestCategories
. Changing to IReadOnlyList<string>?
would require interface changes and break the typical usage pattern shown in tests and examples. The interface already provides read-only access (IList<string>? TestCategories { get; }
), so consumers through the interface can't modify the collection.
// Merge test categories from the test data row with the existing categories | ||
if (testCategoriesFromTestDataRow is { Count: > 0 }) | ||
{ | ||
var existingCategories = discoveredTest.TestCategory ?? []; |
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 use explicit type here please.
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.
Changed to explicit type declaration: string[] existingCategories
(41270af)
{ | ||
mergedCategories.Add(category); | ||
} | ||
discoveredTest.TestCategory = [.. mergedCategories]; |
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 please add a blank line between the closing }
and this line.
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.
Added proper blank line spacing between the closing brace and the following comment (41270af)
…atting Co-authored-by: Evangelink <[email protected]>
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:
|
This PR adds support for applying test categories to individual test data rows in parameterized tests, addressing a long-standing user request for more granular test categorization.
Changes
Core API Changes
TestCategories
property toITestDataRow
interfaceTestCategories
property inTestDataRow<T>
class with[DataMember]
attributeDiscovery Logic Updates
TestDataSourceHelpers.TryHandleITestDataRow()
to extract test categories from test data rowsAssemblyEnumerator
to merge test categories from test data rows with existing method/class/assembly level categoriesUsage Example
Benefits
Test Coverage
TestDataRow
andTestDataSourceHelpers
This enables scenarios like:
Fixes #4089.
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:
5rqvsblobprodcus385.vsblob.vsassets.io
/home/REDACTED/work/testfx/testfx/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:quiet /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.25316.2.txt
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.