-
Notifications
You must be signed in to change notification settings - Fork 949
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
Add test coverage for CheckedListBox.CheckedItemCollection and CheckedIndexCollection #11384
Add test coverage for CheckedListBox.CheckedItemCollection and CheckedIndexCollection #11384
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11384 +/- ##
===================================================
+ Coverage 74.27372% 74.29662% +0.02290%
===================================================
Files 3025 3027 +2
Lines 626861 627151 +290
Branches 46742 46761 +19
===================================================
+ Hits 465593 465952 +359
+ Misses 157926 157852 -74
- Partials 3342 3347 +5
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Other than small comment, LGTM.
...dows.Forms/tests/UnitTests/System/Windows/Forms/CheckedListBox.CheckedItemCollectionTests.cs
Outdated
Show resolved
Hide resolved
|
||
namespace System.Windows.Forms.Tests; | ||
|
||
public class CheckedListBox_CheckedItemCollectionTests : IDisposable |
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 prefer to create controls for each test to ensure that we start with a clean control every time
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 see that test class is created before every test is run, but are we guaranteed that the constructor is executed on the STA thread? and that DIspose method is always called even if the test fals?
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 are following this reference: constructor and dispose pattern.
A TestInitialize like method does not exist in xunit, we have added an empty construct for its uniform operation.
As far as we know, when test cases are run in pipeline, they are randomly assigned to the machine each time and then executed by the vstester, one test case at a time. So, there will be no case of multiple test cases running at the same time.
Are we going to continue to write like this or are we going to use the original creating controls for each test?
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 for the pointer to docs. My other concern was that winforms controls should be used from the same thread they are created on. But in your cases you are not calling CreateControl, only the constructor. So Disposable pattern looks fine.
Related #10453
Proposed changes
Microsoft Reviewers: Open in CodeFlow