TDD: Testing with Stub Methods

Please see my other Test Driven Development articles.

Adding flexibility to return values using Stub methods.

Continuing on my “Testing with Dummy objects” article, you might have noticed a limitation with regards to the return value – only one was allowed.
In situations where multiple return values are needed, Stub methods provide an alternative.



In my previous example, GetSalesOutcome() only provided one return value.
However, if I need my test method to return multiple values for more flexible testing, I may rewrite my test method to accommodate that need.



As you can see, the test still passes, but now I am able to use a much more flexible test, in this case testing for multiple sales associates.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s