Java Reference
In-Depth Information
return result;
}
}
Now we've placed the original code inside a try block, so that if factorsOf() throws
an exception, we can pass it on to the catch block and handle the error. We know that if
there is an error, all we need to do is return false, so we set the variable result to be false.
Then in the finally block, we simply return result , which should be true or false.
Now we'll test our code again by refreshing the SpecRunner.html page. I trust your results
are similar to the screenshot in Figure 10.8 .
Figure 10.8. Passing with flying colors
Hooray! All our tests are now passing. We'll stop there, but I hope that this demonstrates
how TDD can be used to keep adding functionality in small increments using the fail, pass,
refactor cycle.
Search WWH ::




Custom Search