The next challenge is to write a test. This video contains the instructions for what to do.
- [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 length of the string is not 10 digits…
Author
Released
10/25/2018Skill Level Intermediate
Duration
Views
Related Courses
-
Spring: Test-Driven Development with JUnit
with Shonna Smith1h 12m Intermediate -
Java: Testing with JUnit
with Peggy Fisher1h 10m Intermediate -
Learning JUnit 5
with Boni García1h 5m Beginner
-
Introduction
-
Welcome2m 33s
-
-
1. What Is Test-Driven Development?
-
What do you want to test?1m 56s
-
2. Introducing JUnit
-
The case study2m 8s
-
JUnit basics3m 39s
-
-
3. Writing Your First Tests
-
Examples and outcomes2m 58s
-
Getting to red6m 7s
-
Getting to green2m 4s
-
Adding more tests4m 13s
-
Finally writing some code3m 47s
-
-
4. Practicing the Basics
-
Testing for exceptions5m 17s
-
Challenge 129s
-
Challenge 22m 25s
-
Walkthrough 31m 51s
-
Using TDD to safely fix bugs6m 52s
-
-
5. Refactoring
-
Introducing refactoring5m 50s
-
Restructuring code4m 25s
-
-
6. Best Practices
-
Good and bad tests8m 31s
-
JUnit asserts3m 19s
-
-
7. Stubs
-
Building an example10m 15s
-
Creating the stub3m 48s
-
8. Mocking with Mockito
-
Why mocks are useful5m 58s
-
Creating a mock7m 25s
-
Testing behaviour9m 21s
-
Mockito syntax options2m 29s
-
-
9. Fakes and Tautologies
-
Challenge 538s
-
Walkthrough 53m 55s
-
Using setUp and tearDown7m 24s
-
Tautologies3m 26s
-
How to avoid tautologies5m 52s
-
10. Handling Legacy Code
-
Adding Mockito3m 3s
-
Setting up the tests6m 25s
-
The need for spying7m 46s
-
Challenge 61m 15s
-
Walkthrough 6, part 14m 34s
-
Walkthrough 6, part 27m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Challenge 2