show actual values in error message#1196
Conversation
... instead of just throwing an empty runtime exception
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1196 +/- ##
============================================
- Coverage 92.35% 92.10% -0.25%
- Complexity 2821 2891 +70
============================================
Files 292 300 +8
Lines 5609 5726 +117
Branches 599 618 +19
============================================
+ Hits 5180 5274 +94
- Misses 275 293 +18
- Partials 154 159 +5 ☔ View full report in Codecov by Sentry. |
One "s" and one "not" were not needed. The intended variant was: `Not all of [1,2,3,4,3,6,3,7] are equal to 3.`
|
Thanks for your contribution @asolntsev it seems there was a long standing issue with this test, which apparently started to reproduce with your PR [1] on Windows only... About the issue: int[] lastIters = getIterations(threads);
while (true) {
Thread.sleep(100);
int[] iters = getIterations(threads);
if (Arrays.equals(lastIters, iters)) {
// Either all threads are done, or something is probably stuck
System.err.println();
if (allElementsEqual(iters, iterationsPerThread)) {
break;
} else {
printIterations(iters);
throw new RuntimeException();
}
}On Windows it could happen that we reach the line [1] https://github.com/datafaker-net/datafaker/actions/runs/9138381122/job/25130594393#step:4:792 |
|
@snuyanzin Thank you for sharing the information. |
| void issue759Test() throws InterruptedException { | ||
| int numThreads = 5; | ||
| int iterationsPerThread = 20000; | ||
| CountDownLatch countDownLatch = new CountDownLatch(numThreads * 20000); |
There was a problem hiding this comment.
nit: i guess we could reuse the second var as well
| CountDownLatch countDownLatch = new CountDownLatch(numThreads * 20000); | |
| CountDownLatch countDownLatch = new CountDownLatch(numThreads * iterationsPerThread); |
|
@asolntsev Indeed it is better approach I left one tiny comment |
the goal of this test of to verify that Faker doesn't fail in multi-threaded environment. So it's enough to just check that all steps has been executed without any failures. 1. CountDownLatch initially contains total steps count, 2. Every test step decreases this by one, 3. And the test just waits until the counter becomes 0.
... instead of just throwing an empty runtime exception.
Problem
Before this change, test might fail with an unclear message:
or the output of multiple failing tests might be mixed:
Solution
Now the error message is clear:
P.S.
To reproduce the issue, just put breakpoint, say, to any field of
WorkerThread, runIssue759test in debug mode and resume the execution after stopping on the breakpoint.