This means that the program will not halt within a given method
even if we pass an invalid account_id or if some type of database communication error occurs.
?– Note Without proper testing, handling exceptions by passing a nil value makes debugging very difficult,
because it??™s very quietly handling potentially fatal errors. If, for example, a record was not found, the program
would continue on and fail only when a future part of the program expected to deal with the results of
a method and instead found a nil value. Most programmers who are believers in unit testing would not be
very happy to see this type of exception handling in your code, but we use it here to help illustrate the benefits
of good testing in identifying issues that your code may otherwise unintentionally mask.
Now that we have a very simple program, we can write our first test against it. Here, we
will just do the most basic of tests??”checking to see if the right message is returned for the
account ID we pass in (this, of course, assumes we know the data that should be associated to
the given ID, but we??™ll talk about that more in a minute).
Pages:
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302