[erlang-questions] Fault injection for testing?
Mon Dec 20 16:14:11 CET 2010
Why don't you test the various situations that could elicit an error?
The filename is a directory.
Out of space or quota is used.
The path doesn't exist.
On 12/20/10 2:32 PM, Attila Rajmund Nohl wrote:
> Testing error handling is complicated, because it might be hard to
> cause the error situation in the first place, which in my case it's a
> file writing error:
> case file:write_file(FileName,<<Index:8/integer>>) of
> ok -> ok;
> Error ->
> io:format(standard_error, "~p ~p Error: '~p' ~n", [?MODULE, ?LINE, Error]),
> I could modify my code to fail is some debug flag is turned on, but it
> has a (minor) performance impact. My other idea is to make sure that
> the write_file fails by injecting the fault into the OTP library, i.e.
> before the testcase runs in the automatic tests, load a faulty 'file'
> module where the write_file function fails (I happen to know the
> filename, so it won't fail for other uses), execute the testcase, then
> remove the faulty file module.
> Do you have any other ideas on how to test these kind of error
> handling code? Testing the function separately, outside the whole
> application doesn't do it, because it wouldn't detect possible
> deadlocks (the original version of this code actually had a deadlock).
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
More information about the erlang-questions