-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix bug #543: Unstable behavior in PredictRating() #544
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
Fix bug #543: Unstable behavior in PredictRating() #544
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #544 +/- ##
==========================================
- Coverage 96.67% 96.67% -0.01%
==========================================
Files 279 279
Lines 11015 11013 -2
Branches 1568 1568
==========================================
- Hits 10649 10647 -2
Misses 232 232
Partials 134 134 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Please resolve conflicts |
I'm done, thanks @siriak |
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 fixes an intermittent test failure in the PredictRating()
unit test caused by parallel test execution and shared mock instances. The root cause was that concurrent tests were overwriting shared mock objects, leading to unpredictable test results when the test suite ran in parallel.
- Modernized the
CollaborativeFiltering
class constructor to use primary constructor syntax - Added
[NonParallelizable]
attribute to the problematic test method to prevent race conditions - Removed redundant test methods to simplify the test suite
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
CollaborativeFiltering.cs | Updated to use C# primary constructor syntax for cleaner code |
CollaborativeFilteringTests.cs | Added NonParallelizable attribute and removed duplicate test methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Looks good, thanks!
Related issue
#543 Unstable behavior in PredictRating() unit test due to constructor field shadowing
Affected module
CollaborativeFilteringTests.cs
Root Cause
The instability was not caused by the algorithm itself, but by the test fixture design:
[SetUp]
methods overwrite these fields while this test is still executing..Returns(0.8)
) is replaced mid-run by a fresh, unconfigured instance, causing:Fix Summary
Use the
[NonParallelizable]
flagUnit Test Passed Evidence