1 00:00:00,000 --> 00:00:04,937 [MUSIC] 2 00:00:04,937 --> 00:00:09,880 Hi I'm Ben and in this course we'll be learning about testing an Android. 3 00:00:09,880 --> 00:00:13,310 Now I know you've already learned about testing in Java, but as you may have 4 00:00:13,310 --> 00:00:18,106 expected, testing in Android requires a slightly different approach. 5 00:00:18,106 --> 00:00:21,340 For starters, there's [LAUGH] not really a clear consensus about how we should 6 00:00:21,340 --> 00:00:23,780 incorporate testing into our apps. 7 00:00:23,780 --> 00:00:27,600 So in this course, we'll be going over three of the most popular choices for 8 00:00:27,600 --> 00:00:28,230 app tests. 9 00:00:29,290 --> 00:00:31,960 You'll see exactly how to use each one, but 10 00:00:31,960 --> 00:00:36,380 more importantly, you'll learn how each one takes a different approach to testing. 11 00:00:36,380 --> 00:00:39,350 So when it comes time to add tests to your next project, 12 00:00:39,350 --> 00:00:42,600 you can pick the right tool right from the start. 13 00:00:42,600 --> 00:00:44,510 But before we get to the tools, 14 00:00:44,510 --> 00:00:47,470 let's take a minute to see what's wrong with our current approach to testing. 15 00:00:48,660 --> 00:00:52,510 Let's start by downloading the project we'll be using from GitHub. 16 00:00:52,510 --> 00:00:54,900 The link is down below in the teacher's notes. 17 00:00:54,900 --> 00:00:59,370 There's also a link to a workshop on how to use GitHub with Android Studio 18 00:00:59,370 --> 00:01:00,010 in case you need it. 19 00:01:01,350 --> 00:01:06,970 Let's click Check out project from Version Control > pick GitHub, 20 00:01:06,970 --> 00:01:10,440 paste in the Repository URL, and then hit Clone. 21 00:01:12,700 --> 00:01:14,910 And hit Yes to check it out from Version Control. 22 00:01:17,410 --> 00:01:21,960 Then, it looks like we're having an error loading three modules. 23 00:01:24,080 --> 00:01:25,200 Let's choose to keep these. 24 00:01:27,450 --> 00:01:29,410 Now that we've got the project imported, 25 00:01:29,410 --> 00:01:32,340 let's take a minute to see what we'll be testing. 26 00:01:32,340 --> 00:01:35,790 Let's start by running the app to first make sure that it works. 27 00:01:36,790 --> 00:01:40,504 If it doesn't work, it's likely that the project is referencing something and 28 00:01:40,504 --> 00:01:43,576 it's build.Gradle file that isn't installed on your machine. 29 00:01:59,487 --> 00:02:02,085 All right, here's the app. 30 00:02:02,085 --> 00:02:07,955 We've got a text view up top and below is an edit text, a spinner and a button. 31 00:02:09,010 --> 00:02:14,500 If we change the edit text, hello world, and 32 00:02:14,500 --> 00:02:18,430 then click the check, it updates the text view. 33 00:02:18,430 --> 00:02:23,690 The spinner updates the background color and 34 00:02:23,690 --> 00:02:29,330 the launch activity button launches this other activity, very exciting. 35 00:02:30,390 --> 00:02:34,100 As you might have guessed, our goal in this course will be to successfully test 36 00:02:34,100 --> 00:02:35,990 each of those three things. 37 00:02:35,990 --> 00:02:39,950 So changing the added text should update the text view. 38 00:02:42,120 --> 00:02:46,623 Selecting a spinner item should update the background color. 39 00:02:46,623 --> 00:02:51,961 And clicking the Launch Activity button should launch this other activity. 40 00:02:51,961 --> 00:02:56,128 But before we get to the tests, 41 00:02:56,128 --> 00:03:01,099 let's quickly look through the code 42 00:03:01,099 --> 00:03:05,277 as well over in main activity. 43 00:03:05,277 --> 00:03:10,136 We've got the fields for our views up top, then and 44 00:03:10,136 --> 00:03:15,108 on create we set our layout, initialize our views, 45 00:03:15,108 --> 00:03:20,650 set up the spinner and then we add our actions to our views. 46 00:03:22,080 --> 00:03:26,745 Updating the text view when we change the edit text, 47 00:03:26,745 --> 00:03:32,260 changing the background color when we select a spinner item, 48 00:03:32,260 --> 00:03:38,958 and starting the other activity when we click the Launch Activity button. 49 00:03:38,958 --> 00:03:40,360 So far so good. 50 00:03:40,360 --> 00:03:42,730 In the next video, we'll start adding some tests.