c# - Is there a common way to test complex functions with NUnit? -
is there common way test complex functions several parameters nunit? think hard or impossible test every condition.
i'm afraid combination of parameters isn't expected in function not expected in test.
so expected condition not fail unexpected.
thanks
this shouldn't hard test @ all. if is, method isn't designed testability, , code smell tells you need refactor it.
i tend write tests in these cases follows (others may have better suggestions):
- does work intended when appropriate parameters passed?
- does throw expected exceptions when think should? (argumentnullexception, etc.)
- for each parameter, happens when pass null, minimum , maximum. (this can extensive, depending on number of arguments.)
if method takes lot of parameters, consider refactoring take object information on it, can encapsulate rules in object, , pass object method.
Comments
Post a Comment