Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,330 --> 00:00:03,030
For this solution, we're gonna cover tasks two and three.
2
00:00:11,860 --> 00:00:16,870
Going back to the third test case, we need to write a unit test that expects cell movie to throw an
3
00:00:16,870 --> 00:00:19,180
exception if a movie has already been rented.
4
00:00:22,310 --> 00:00:25,340
So here I can write a unit test that expects an illegal state exception.
5
00:00:26,360 --> 00:00:27,830
Test expected.
6
00:00:29,390 --> 00:00:31,970
And it expects an illegal state exception.
7
00:00:35,300 --> 00:00:36,200
DECLASSE.
8
00:00:43,520 --> 00:00:46,400
The unit test is called Movie Night in Stock.
9
00:00:49,120 --> 00:00:50,920
First, I'll rent The Godfather.
10
00:01:02,820 --> 00:01:04,800
And then I'll try to sell The Godfather.
11
00:01:09,630 --> 00:01:10,980
If I run the test now.
12
00:01:14,050 --> 00:01:18,820
It fails, it's expecting the test to throw in a legal state exception, but it isn't.
13
00:01:20,120 --> 00:01:24,710
And so now we need to make the test pass by throwing an illegal -- exception from sell movie.
14
00:01:35,750 --> 00:01:37,670
If the movie is already rented.
15
00:02:02,200 --> 00:02:03,940
Throw an illegal STD exception.
16
00:02:19,520 --> 00:02:21,830
Rerun the test and perfect.
17
00:02:24,170 --> 00:02:30,140
And just have a look at how clean and elegant the code is, when you write tests, before you write
18
00:02:30,140 --> 00:02:33,560
code, you're being forced to write code that is easy to test.
19
00:02:34,100 --> 00:02:38,030
At the same time, code that is easy to test won't get any bugs.
20
00:02:40,400 --> 00:02:42,800
And now what I'm going to do is run every single test.
21
00:02:46,760 --> 00:02:51,470
They all pass, which means the code inside Staudt Java doesn't have any bugs.
22
00:02:52,580 --> 00:02:57,380
And before we wrap up, just I want you to really appreciate how polished our code is.
23
00:03:01,850 --> 00:03:08,270
Compared the old code with the new code in the old code, the functions were massive, this function
24
00:03:08,270 --> 00:03:09,940
here is impossible to test.
25
00:03:10,340 --> 00:03:13,430
So if you get a bug here, it's going to be really hard to fix.
26
00:03:14,000 --> 00:03:21,290
In general, this is not good coding, but with unit testing, our code is a lot cleaner and immune
27
00:03:21,290 --> 00:03:22,070
to bugs.
2514
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.