Hey all!
I am writing some Oracle PL/SQL unit tests for a wrapper to an Oracle API
(Advanced Queueing). I'm having a problem with one test, which exercises a
procedure to flush the contents of a message queue. The code is correct but
the test frequently - not always - fails.
This is because the Oracle API works in an asynchronous fashion. I execute
the code to clear all the messages from the queue and /some/time/later/ all
the messages will be cleared from the queue. The problem is, my test that
this has happened (count=0) frequently fails because it hasn't happened when
my assertion runs.
Currently, I have a ten second sleep in my unit test. This means the test
passes sometimes and fails at other times. I have put an explanatory
message in the assertion code, but this strikes me as unsatisfactory. I
could further increase the sleep time in the unit test but who wants to wait
a minute for their tests to run? I can say "well it works" and remove the
unit test, but I don't like losing the coverage.
I'm sure people must have come across similar problems. There are probably
technology specific solutions (if you're working with Java Threads, say) but
is there a generic solution (pattern, approach)?
Cheers, APC
This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential information
and/or be subject to legal privilege. It should not be copied, disclosed to,
retained or used by, any other party. If you are not an intended recipient then
please promptly delete this e-mail and any attachment and all copies and inform
the sender. Thank you.