1
00:00:05,900 --> 00:00:06,950
Hey everybody How's it going.

2
00:00:06,950 --> 00:00:11,590
This is Caleb with Deb's slopes dot com and we're here with one final video on you.

3
00:00:11,600 --> 00:00:12,690
Testing for now.

4
00:00:12,890 --> 00:00:20,050
And basically we're going to talk about testing data in fields like text fields etc. etc. and so penélope

5
00:00:20,050 --> 00:00:21,170
in your project here.

6
00:00:21,260 --> 00:00:24,940
And we need to get into actually adding some text fields to our project.

7
00:00:24,950 --> 00:00:25,920
We don't have any yet.

8
00:00:25,970 --> 00:00:33,000
So go to main storyboard and we're going to go all the way back here to our interface visi.

9
00:00:33,020 --> 00:00:36,670
Now let's go ahead and let's add in some text fields here.

10
00:00:37,130 --> 00:00:42,410
And this is going to basically I want you to think of this as if you were creating some type of log

11
00:00:42,410 --> 00:00:44,570
in flow for your application.

12
00:00:44,570 --> 00:00:48,220
And of course you have an email field in a password field.

13
00:00:48,230 --> 00:00:49,190
Right.

14
00:00:49,190 --> 00:00:54,610
So I'm going to go ahead and actually duplicate this and then put it into a stack view.

15
00:00:54,790 --> 00:00:59,080
OK so select both put it into a stack view and then I'm going to Pinet.

16
00:00:59,450 --> 00:01:00,240
Let's do.

17
00:01:00,250 --> 00:01:11,440
Yeah how about 300 from the top let's do 20 20 and let's give it a fixed height known at a fixed height.

18
00:01:11,450 --> 00:01:12,850
Let's just let's just do that.

19
00:01:12,860 --> 00:01:13,930
That's good.

20
00:01:14,150 --> 00:01:18,440
Although Strange that's not supposed to I guess go over that.

21
00:01:18,440 --> 00:01:21,700
So let's actually go ahead and delete this.

22
00:01:21,710 --> 00:01:25,380
Let's move move the whole stack view actually.

23
00:01:25,520 --> 00:01:28,680
And we're going to go ahead and pin this 20 from the bottom.

24
00:01:29,000 --> 00:01:29,590
OK.

25
00:01:29,930 --> 00:01:31,050
There we go.

26
00:01:31,070 --> 00:01:37,190
Now I want to actually give it some spacing here so let's do 20 pieces of spacing or pieces at points

27
00:01:37,960 --> 00:01:42,740
and so set a placeholder here for maybe email that looks good.

28
00:01:43,040 --> 00:01:50,060
Set a placeholder here for password and we can even set it so that it is secure text entry for a password

29
00:01:50,420 --> 00:01:52,390
that be pretty cool.

30
00:01:52,610 --> 00:01:55,750
And now I'm going to go ahead and just say enter.

31
00:01:55,820 --> 00:02:00,120
Well no I guess we are to have a placeholder text there.

32
00:02:00,200 --> 00:02:00,710
Cool.

33
00:02:00,710 --> 00:02:08,150
So I'm going to go ahead and change the background color of this to be green and the background color.

34
00:02:08,150 --> 00:02:09,660
This one to be blue.

35
00:02:09,860 --> 00:02:10,780
Just for fun.

36
00:02:11,030 --> 00:02:15,320
And let's set the text color to be white again just for fun.

37
00:02:15,680 --> 00:02:19,680
And then we're going to go ahead and link this to interface visi.

38
00:02:19,760 --> 00:02:26,570
So let's select that let's go into the automatic connection there and let's go ahead and create some

39
00:02:26,600 --> 00:02:27,910
Iby outlets for this.

40
00:02:27,920 --> 00:02:32,260
So this will be email text field.

41
00:02:32,270 --> 00:02:33,000
All righty.

42
00:02:33,590 --> 00:02:37,910
And then this will be password textfield

43
00:02:40,680 --> 00:02:41,460
field.

44
00:02:41,460 --> 00:02:42,220
There we go.

45
00:02:42,540 --> 00:02:47,790
And this is a pretty common way you know to do things pretty cool basic stuff.

46
00:02:47,790 --> 00:02:52,360
And now if we want to test how this works we can just go straight into our UI tests.

47
00:02:52,560 --> 00:02:53,300
OK.

48
00:02:53,670 --> 00:03:02,060
And what we can do is we can test the input here so phunk test let's do email input.

49
00:03:02,100 --> 00:03:03,190
That's what we're going to test.

50
00:03:03,210 --> 00:03:11,750
So when given e-mail fills textfield let's just make sure that the text is actually going into our text

51
00:03:11,750 --> 00:03:12,040
field.

52
00:03:12,060 --> 00:03:13,600
That's important right.

53
00:03:13,650 --> 00:03:19,170
So what we're going to do is we're going to go ahead and launch our app opt out launch then we're going

54
00:03:19,170 --> 00:03:21,470
to go ahead and create an instance.

55
00:03:21,540 --> 00:03:24,870
You can also do this check it out create an instance of our e-mail textfield.

56
00:03:24,870 --> 00:03:31,990
So let email textfield equals app dot text fields.

57
00:03:32,040 --> 00:03:37,830
Or you can also do text views but we're going to choose the one with a particular title so we're going

58
00:03:37,830 --> 00:03:41,030
to go ahead and just say email already.

59
00:03:41,050 --> 00:03:48,690
Now what I can do is I can call email textfield tap tap on the textfield and then we can type email

60
00:03:48,690 --> 00:03:53,500
textfield dot type text and I can give it a string.

61
00:03:53,520 --> 00:03:56,010
So my email could be Caleb.

62
00:03:56,520 --> 00:03:59,820
Caleb at Debb slopes dot com.

63
00:03:59,880 --> 00:04:03,730
And then what we're going to do is we're going to go ahead and say ex-city assert true.

64
00:04:03,900 --> 00:04:12,330
Email textfield dot static texts we're going to go ahead and verify that the static text is in fact.

65
00:04:12,360 --> 00:04:13,460
But def slopes.

66
00:04:13,710 --> 00:04:14,330
OK.

67
00:04:14,760 --> 00:04:18,280
So let's go ahead and let's actually run just this singular test.

68
00:04:18,570 --> 00:04:19,280
Oh you know what.

69
00:04:19,320 --> 00:04:26,720
It does not like that cannot convert value of x c UI element to type bool 0.

70
00:04:26,970 --> 00:04:31,560
We need to do what exists of course we need to make sure that that is actually where it should be.

71
00:04:31,710 --> 00:04:33,940
So perfect run this test.

72
00:04:34,110 --> 00:04:37,180
Pull open your simulator and we can actually see it happen.

73
00:04:37,260 --> 00:04:42,960
It's going to go ahead and launch our app and we'll see how we did.

74
00:04:45,640 --> 00:04:47,650
Oh you know what our test will fail.

75
00:04:47,650 --> 00:04:52,910
It's going to time out because we never actually go back to our UI.

76
00:04:53,110 --> 00:04:55,720
So let's go ahead and let's say

77
00:04:59,390 --> 00:05:00,070
interesting.

78
00:05:00,080 --> 00:05:02,520
So do we have an instance of user defaults here.

79
00:05:02,540 --> 00:05:03,590
We do not.

80
00:05:03,590 --> 00:05:08,120
Let's go ahead and let's just go through the onboarding process just to make this a little bit easier

81
00:05:08,120 --> 00:05:09,640
for us.

82
00:05:09,680 --> 00:05:13,880
Let's run the test again instead of messing with user defaults in the test.

83
00:05:13,880 --> 00:05:17,620
I'm actually just going to go ahead and go through the process where my code sets the user defaults.

84
00:05:17,630 --> 00:05:19,040
You know you know how it goes.

85
00:05:19,400 --> 00:05:24,840
And then we should be able to actually tap on our textfield type some text and then be done.

86
00:05:24,840 --> 00:05:33,990
So all right then I don't know if you saw that I saw that it started typing but I don't know if it finished

87
00:05:33,990 --> 00:05:39,420
so we're not going to actually have to move that textfield up to see if it's actually doing what it's

88
00:05:39,420 --> 00:05:39,990
supposed to.

89
00:05:39,990 --> 00:05:43,750
So I made a bad call putting it so low on the screen.

90
00:05:44,100 --> 00:05:46,530
Let's go ahead and select that stack view again.

91
00:05:46,560 --> 00:05:51,750
Move it up to the top ish side and sure 32 went up.

92
00:05:52,230 --> 00:05:54,250
Let's do that again let's run our test.

93
00:05:54,390 --> 00:05:56,310
OK here we go.

94
00:05:56,310 --> 00:05:57,750
We're going to see what happens.

95
00:05:57,750 --> 00:06:04,050
I'm only running this one test so that should be should be pretty cool if it does what I'm hoping it

96
00:06:04,050 --> 00:06:05,550
does.

97
00:06:05,910 --> 00:06:10,320
The thing I like about this is you can actually kind of simulate what a brand new user would be doing

98
00:06:10,350 --> 00:06:14,140
in your application every time which is really cool.

99
00:06:14,160 --> 00:06:14,560
OK.

100
00:06:14,580 --> 00:06:15,390
Check it out.

101
00:06:15,390 --> 00:06:16,490
That's awesome.

102
00:06:16,710 --> 00:06:19,290
So that is pretty good.

103
00:06:19,290 --> 00:06:31,050
It appears that we did not successfully find static text 0 because static text refers to labels.

104
00:06:31,260 --> 00:06:40,730
We need to actually check to see if Yeah if email field at Caleb.

105
00:06:40,760 --> 00:06:40,970
OK.

106
00:06:40,980 --> 00:06:45,950
So what we're going to do is we're going to actually check app dot WIPs.

107
00:06:46,290 --> 00:06:54,300
We're going to check to make sure that app dot text fields has one with this value because remember

108
00:06:54,300 --> 00:06:56,470
at the beginning it has no value.

109
00:06:56,610 --> 00:06:59,870
And of course at the end the call that exists now run this test.

110
00:06:59,880 --> 00:07:05,630
And we should be able to successfully verify that our information is there.

111
00:07:05,670 --> 00:07:11,380
It should open should type and then we should check to see if that textfield is there.

112
00:07:11,400 --> 00:07:16,140
So swipe through dismiss awesome.

113
00:07:16,540 --> 00:07:20,400
We're going to type and our test passes because that is then.

114
00:07:20,430 --> 00:07:21,460
They're awesome.

115
00:07:21,460 --> 00:07:22,750
Now we can do the same thing.

116
00:07:22,750 --> 00:07:27,610
I'm going to actually go ahead and just copy this and paste it and it's going to be a different test

117
00:07:27,610 --> 00:07:29,550
so password input

118
00:07:32,590 --> 00:07:35,390
when given password.

119
00:07:36,310 --> 00:07:42,700
Word fills textfield So we're going to need to go into the textfield that says password OK and it's

120
00:07:42,710 --> 00:07:49,990
placeholder and we're going to type Manby mamby pamby unicorn's.

121
00:07:49,990 --> 00:07:51,220
Sounds good.

122
00:07:51,220 --> 00:07:57,250
Then we're going to check to verify that my password actually exists and if it does then we know our

123
00:07:57,250 --> 00:07:58,210
test has passed.

124
00:07:58,210 --> 00:08:03,640
So click the diamond open your simulator and we should see the test go through.

125
00:08:03,790 --> 00:08:05,950
Should enter a password for me.

126
00:08:06,240 --> 00:08:12,250
And yeah of course as this gets more complicated you can basically set up you know your code so that

127
00:08:12,280 --> 00:08:17,680
if you don't have a username and password it wouldn't let you do what you want.

128
00:08:17,740 --> 00:08:19,920
And it looks like you that did not work.

129
00:08:19,930 --> 00:08:21,130
So interesting.

130
00:08:21,500 --> 00:08:22,970
Hmm.

131
00:08:23,770 --> 00:08:25,240
No match found.

132
00:08:25,300 --> 00:08:28,590
Oh well this is still called e-mail password that's not going to make a difference.

133
00:08:28,600 --> 00:08:30,940
But I'll go ahead and fix this.

134
00:08:30,940 --> 00:08:36,390
Let's go ahead and let's head back to our storyboard here and see what the deal is.

135
00:08:36,400 --> 00:08:40,180
So this has a placeholder for e-mail.

136
00:08:40,210 --> 00:08:41,830
This has a placeholder for password.

137
00:08:41,860 --> 00:08:45,310
Oh you know what I wonder if secure text entry is getting in the way.

138
00:08:45,310 --> 00:08:49,360
Let's go ahead and let's test it and then see if that is in fact getting in the way.

139
00:08:50,080 --> 00:08:54,340
Because I guess the text is obscured by the secure text entry.

140
00:08:54,520 --> 00:08:58,760
We're checking if password is indeed there.

141
00:08:58,960 --> 00:09:01,090
Then we tap on it then we type text.

142
00:09:01,090 --> 00:09:02,260
And that should be it.

143
00:09:02,260 --> 00:09:03,130
So swipe through

144
00:09:06,050 --> 00:09:09,820
a tap on the textfield k we type our password.

145
00:09:09,820 --> 00:09:10,840
That's awesome.

146
00:09:11,050 --> 00:09:16,960
So I guess when you're testing leave it as plain text but when you submit it for production you can

147
00:09:16,960 --> 00:09:20,480
always change it to you know secure text entry that's fine.

148
00:09:20,500 --> 00:09:24,370
Well it's good to know that it really is very very secure even from you.

149
00:09:24,580 --> 00:09:31,600
So this is how you can test the input on text fields text views et cetera et cetera to ensure that your

150
00:09:31,600 --> 00:09:36,910
data is actually going in and is getting validated in the way that you hope you eye testing when combined

151
00:09:36,910 --> 00:09:42,760
with unit testing is a very powerful way to ensure that future problems are never introduced into your

152
00:09:42,760 --> 00:09:44,800
app because your tests will fail.

153
00:09:44,800 --> 00:09:46,350
This is very very cool stuff.

154
00:09:46,360 --> 00:09:50,950
And we're going to head over now to an exercise where you're going to put your knowledge of UI testing

155
00:09:51,250 --> 00:09:52,190
to the test.
