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 should use theory data #11171
base: main
Are you sure you want to change the base?
Tests should use theory data #11171
Conversation
A typed theory data object is used in the test for building the apps configuration.
The test now uses a typed theory data object for the configuration generator tests.
A typed TheoryData Obejct is now used to pass in parameters to the Font converter test.
…winforms into Tests_should_use_TheoryData
@dotnet-policy-service agree |
For the testing environments, would you like me to paste my dotnet --info or could I remove it? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11171 +/- ##
===================================================
- Coverage 73.44664% 73.44649% -0.00016%
===================================================
Files 3098 3098
Lines 632225 632229 +4
Branches 46653 46653
===================================================
+ Hits 464348 464350 +2
- Misses 164485 164487 +2
Partials 3392 3392
Flags with carried forward coverage won't be shown. Click here to find out more. |
{ | ||
var testData = new TheoryData<OutputKind>(); |
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.
[nit]
var testData = new TheoryData<OutputKind>(); | |
TheoryData<OutputKind> testData = new(); |
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.
Left a few comments, thanks for helping out in this area!
[MemberData(nameof(TestConvertFormData))] | ||
#pragma warning restore xUnit1042 // The member referenced by the MemberData attribute returns untyped data rows |
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.
We typically do not want this comment twice for suppressions
#pragma warning restore xUnit1042 // The member referenced by the MemberData attribute returns untyped data rows | |
#pragma warning restore xUnit1042 |
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.
The comment in both locations is automatically added by Roslyn's code fix
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.
Yep, for the most part we've been manually removing the comment on restore when adding these warnings
testData.Add | ||
( |
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.
nit:
testData.Add | |
( | |
testData.Add( |
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 would have expected this one to be flagged by analyzers
@@ -57,7 +57,9 @@ public static IEnumerable<object[]> TestConvertFormData() | |||
} | |||
|
|||
[Theory] | |||
#pragma warning disable xUnit1042 // The member referenced by the MemberData attribute returns untyped data rows |
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.
What change caused this warning?
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.
Sorry for the delay. Disabling the warning addressed the function uses an enum that is marked as internal. So I was not able to put it into a TheoryData<...> object getting a CS0050 error. I thought disabling was the best course of action for this specific test case.
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.
Ah I see. Thank you for your explanation. I think disabling for this case is fine.
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.
If this is a common situation (it may be), we could implement a DiagnosticSuppressor
that automatically suppresses xUnit1042 for these cases.
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.
Thank you all for the help and comments.
@@ -113,4 +115,4 @@ public void EmptyStringInput() | |||
Assert.Null(font); | |||
} | |||
} | |||
} | |||
} |
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.
This seems undesirable. I can understand not forcing it to move the other direction to fix a problem, but this is creating a problem where there wasn't one.
@woefulpines could you update PR with feedback addressed so we can take this to completion? Let me know if there are any concerns :) |
Makes progress to fix #11041
Proposed changes
for the file reader font converter.
Customer Impact
Regression?
Risk
-There should be no risk in moving to strongly typed parameterized test methods.
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow