From the course: Practical Test-Driven Development for Java Programmers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Challenge 2

Challenge 2

- [Instructor] Now before we go on, I want to just mention that in this instance, we've used an unchecked exception, this number format exception. We might discover later that there is a requirement to make this a checked exception. If that turns out to be the case, we will need to change this. But unless we know that that is the requirement, what we have is fine. And I'm pointing this out because I think this is quite a good example of the kind of thing that happens in test-driven development. We don't really know all the business requirements in detail. We're building with what we do know. But if we discover later that a checked exception is required, we can change this and we can use the test that we've built to check that nothing else is impacted by this change. Now at this stage, you could if you wanted, create more tests to check 11-digit numbers, or eight-digit numbers, but I think that is a waste of time. We know that our number format exception is going to be flown if the…

Contents