testing - Exception order when multiple are possible -


if function has 2 arguments , both produce exceptions, order have them raised in , define it?

this came when writing test function take directory on disk , compress file. instance:

void compress(string dirpath, string filepath); 

i haven't written function yet , i'm putting tests in place.

the thing is, if directory path doesn't exist i'd have exception missing directory thrown , if file had write permissions in way i'd have exception thrown show that. however, if both paths cause exceptions? throw first, second, third one, or unknown state? we'd considered having single exception "something broke", message different in each case doesn't help.

i've thought of few ways around such throwing based upon left right processing of arguments, or stating "if dirpath invalid x thrown else if filepath invalid y thrown" , placing interface definition whoever implements should (hopefully) follow specification.

just wondering approach people take problem.

for reference, in c# don't think language specific problem.

i leave unspecified. documentation say:

possible exceptions include: x if dirpath invalid; y if filepath invalid.

if there's unit test both invalid, pass long either of 2 exceptions thrown.

because really, depends on exception happens when there multiple exception-worthy problems not idea.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -