random sleeps are making my duplicate-event test useless

WillBaker0487 · 8 Jul 2026, 21:53 UTC

Reply to discussion
WI
WillBaker0487
An old completion can finish the NEW inspection attempt in our offline FR5 test. I can make it happen by delaying a message, but not reliably with the sleeps I've scattered about. I want a repeatable sequence: start A, start B, deliver A's result late, then deliver it again. What's the cleanest way to control delivery without turning the test into a second broken version of the application?

10 replies

OM
OmarCarter1013
Replying to WillBaker0487

Put a queue at the test delivery boundary. Enqueue named events, release them explicitly in the order you want. The application should still use its normal handler; don't recreate the reconciliation logic inside the test.

22 points
AN
AnilAli0201
Replying to WillBaker0487

Does the old result actually carry A's identity, or is the test inventing that field?

17 points
WI
WillBaker0487
Replying to AnilAli0201

Our fixture messages carry an attempt identifier. I'm checking that against the real recorded interface before I trust the test. Omar, explicit release is what I was missing.

7 points
WI
WillBarnes0574
Replying to OmarCarter1013

Include the expected count after each delivery. Otherwise the final count could look right while an earlier screen state was wrong.

1 points
OM
OmarCarter1013
Replying to WillBarnes0574

Yes, and assert which attempt changed, not just the total. A counted result attached to the wrong item can hide behind the same number.

21 points
WI
WillBaker0487
Replying to OmarCarter1013

Got the bad sequence repeatable without a single sleep. It fails on delivery of A, exactly where it should. Weirdly satisfying to have a reliably broken test.

13 points
CA
CallumBrown0882
Replying to WillBaker0487

That is useful. Keep that sequence as a named case, including the expected state of both attempts. Someone diagnosing a later regression should not need to rediscover the timing trick from a pile of unexplained messages.

11 points
AN
AnilAli0201
Replying to WillBaker0487

Any result on the real-message identity check, Will? That's still the loose end.

8 points
WI
WillBaker0487
Replying to AnilAli0201

Not signed off yet. The revised offline handler leaves B pending when A arrives and ignores the repeated delivery for counting. Real-message mapping is still with the interface owner.

8 points
WI
WillBarnes0574
Replying to WillBaker0487

Thanks for coming back with that distinction. I would keep the test result and the interface check as separate handover entries until both are complete.

12 points

Add to the discussion

Welcome to Application Robot

Everyone can read the forum. Sign in or create an account to start a discussion, reply, or upload photos.

Forgot your password?

By creating an account, you agree to our Terms and Conditions and community guidelines. Read our Privacy Policy for how your information is handled.