[MUSIC] One of the hardest thing in software development is that it's very, very difficult, if not impossible, to predict what's going to happen when we write some lines of code or we make some changes to some existing code. So, often we'll think that we know what we're doing. We will have a pretty good idea that adding a certain set of instructions is going to get us the result we want. But when we go and we actually implement that idea with the way that we think that we should do it, what we see is is that the desired result is not what we want. And this is why testing is one of the most critical pieces of building software. You can't build maintainable and evolvable apps if you don't have ways of testing them. Because if you don't test them, there's no way to tell for sure that What you expected to be the result is actually what's going to be the result. So let's say, for example, that we're building a GUI application. So we've got our Android app, let's say maybe it has a set of text boxes that the user can type into. Then maybe it has a drop-down where they can make some selection that they're interested in, and then maybe we have a button And commonly what we like to do is we like to say, well, I programmed these things. I'm going to go and make a change to this button right here. And then what we do is we say, well, okay, I'll open up my app. I'll try this drop-down and try the new thing that I've just added, and I'll see if it works. And then, what happens is we say, well it worked. I'm all set, and we go off and we're done. But the reality is is that our changes here may end up impacting these other elements of our application. And there's absolutely no way to guarantee, well there are ways, but, in general, it's difficult to guarantee that our changes here aren't going to have implications or ramifications up here. So what do we have to do when we make these changes? Well, every time we change something, and this needs to be a fundamental concept in our building of software. Every time we create something new, every time we make a change, we have to have a way of measuring its impact. Of testing what the impact of that change was, how it affects things that we care about, and then being able to go back and ensure that, as we're evolving this piece of software, we're evolving it to make it better. And continually improving things rather than simultaneously hurting things that we've already done. So testing is what we do to ensure that, as we're building, we are trying to guarantee that the changes that we're making, that the things that we're creating, are actually helping and aren't simultaneously hurting. Now, one of the things that we have to be concerned with is, how do we know what to test? And this is a very, very difficult problem. In general, what we're going to see is is that we want to test as much as possible. And it sounds like a really bad answer, but, unfortunately, it's probably the best answer that we have right now in software engineering. We try to test as much as possible, we try to cover as many possible ramifications of our change as we can in order to ensure that, as we're evolving the software, we're not hurting things. So in this sequence of lectures, what we're going to be looking at is, in Android, how do we build ways of testing apps more efficiently? And how do we reduce the load on you as a programmer to build tests? Now, as a programmer, one of the things that we kind of sometimes get lazy about is we feel that testing is an extra burden. A lot of people have learned about testing, but they don't actually employ it. And so we want to try to figure out what are the things we can do to make testing easier, possibly more fun, and we want to give ourselves a sense of security to some degree. Now we should never be perfectly secure and assume that our software is perfect, because that's almost never the case. More than likely, your software is broken in some way and you just haven't written the test to find it yet. Or you haven't given it out to your users who test it for you and then tell you about it, which is a much harder and more expensive way of testing. So what we're trying to do is make it as likely as possible that we've tested all the things that are important. That we found the bugs, as many of them as possible, before we hand these apps out to our users. And we do this in the most efficient and least burdensome way to the software developer. So the tools we'll be talking about, and the techniques that we'll be talking about in these lectures, unit testing, integration testing, exploratory testing. Different styles of building our code to make it more testable, different ways of taking pieces of our code and separating them so that we can test them more efficiently. And when thinks break, know not only that the test failed, but have a good indication of why the test failed and be able to hone in on the source of errors very quickly.