Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,530 --> 00:00:05,990
In the last few meters we have learned about the basics of unit testing in flutter and we are now ready
2
00:00:05,990 --> 00:00:12,140
to test a class that is a little bit more complex than the non empty string validator and in the process
3
00:00:12,140 --> 00:00:16,230
of doing this we will learn a bit more about the flutter testing API.
4
00:00:16,520 --> 00:00:23,750
So as a next step we can open the four month class that we use to format our words dates and currency
5
00:00:23,750 --> 00:00:25,290
values in the up.
6
00:00:25,460 --> 00:00:34,050
And then we can add a new Dart file called for format on the score fast inside the test packets.
7
00:00:34,100 --> 00:00:42,740
And like we have done before we can import faster test and we can also add a void Main method like this
8
00:00:43,820 --> 00:00:45,370
and to make our life easier.
9
00:00:45,370 --> 00:00:51,770
We can split up what Ed into and keep the did testify on the left and the file that we want to test
10
00:00:51,800 --> 00:00:52,720
on the right.
11
00:00:52,880 --> 00:00:58,730
And as we can see here we have four different methods and we could write multiple tests for each of
12
00:00:58,730 --> 00:00:59,170
them.
13
00:00:59,240 --> 00:01:03,560
So it would be nice if somehow we could group the tests that belong together.
14
00:01:03,770 --> 00:01:10,870
And it turns out that we can do that by using a test group so we can type being group like this without
15
00:01:10,890 --> 00:01:11,740
description.
16
00:01:11,750 --> 00:01:18,550
And here we could type being ours and then we need to pass a closure like this.
17
00:01:18,840 --> 00:01:21,470
And inside the body of this closure we cannot.
18
00:01:21,500 --> 00:01:23,750
All the tests for this method.
19
00:01:23,750 --> 00:01:25,520
So let's start with the first one.
20
00:01:25,730 --> 00:01:32,680
And here I can type test a description of positive and then inside the test body.
21
00:01:32,780 --> 00:01:42,590
I'm going to write expect that for month and I need to import this second draft format that house with
22
00:01:42,680 --> 00:01:50,330
a parameter of 10 for example is equal to 10 H which is the string representation that I want and if
23
00:01:50,330 --> 00:01:55,190
I want I can already run this test and as I can see.
24
00:01:55,210 --> 00:01:56,200
Now this is green.
25
00:01:56,230 --> 00:01:57,870
So we can continue.
26
00:01:58,030 --> 00:02:04,300
Next I want to add more tests and I'm particularly interested in what happens when we pass zero.
27
00:02:04,660 --> 00:02:11,530
When we pass on negative value and when we pass a decimal number so let's up this test quickly and I
28
00:02:11,530 --> 00:02:19,090
can copy and paste this method in here I can rename the description to zero and I can pass for month
29
00:02:19,180 --> 00:02:28,580
of ours with zero and I expect zero H and then I can do the same thing for the negative case.
30
00:02:29,420 --> 00:02:37,000
And here I could pass for example hours of minus five and I'm still going to expect to see zero hours
31
00:02:37,330 --> 00:02:40,780
because this is how this logic was implemented.
32
00:02:40,870 --> 00:02:50,320
Finally I cannot the decimal case so I can copy paste this I'm going to name this decimal and I'm going
33
00:02:50,320 --> 00:03:01,150
to pass a value of 4.5 an unexpected value of 4.5 H and then I can run all the tests again and I can
34
00:03:01,150 --> 00:03:03,040
see that they have all passed.
35
00:03:03,480 --> 00:03:05,590
OK so let's continue on the next video.
3753
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.