[erlang-questions] Re: testing asynchronous code

Martin DeMello martindemello@REDACTED
Tue Apr 20 08:30:24 CEST 2010


On Mon, Apr 19, 2010 at 5:26 PM, Tim Fletcher <mail@REDACTED> wrote:
>> Anyone have general strategies or advice for testing code that makes
>> heavy use of gen_server:cast? The best I could come up with was to
>> write _sync versions of all my functions, with gen_server:cast
>> replaced by gen_server:call, and then test those, but that seems both
>> clunky and fragile.
>
> How about using a "test spy" process to collect a trace of the cast
> messages and then make assertions against the resulting trace?

Thanks, that's an interesting suggestion. I take it the basic idea is
to unit test all the underlying synchronous code separately, and then
assert that if the low-level code works, and all the casts are going
out as specified, then the high-level code is correct?

martin


More information about the erlang-questions mailing list