>> All right, so they're really, there's kind of two strategies for testing.
One is, you can be like Scott and just never write any erroneous code.
Just no bugs, perfect the first time through.
>> That seems the best way.
>> [LAUGH] Unfortunately, I don't think we can all teach you to be like Scott.
[LAUGH] However there's a second approach, and I want to say a little bit about my
experience in teaching students to program.
I teach and on campus version of an intro to programming class, and i also teach
introduction to interactive programming in Python, and we've run through
five sessions now, and in those sessions I've seen lots and lots of bad code.
And probably the worst case that I see is when a student is working on
a mini-project and they go and they essentially write the entire program.
They take it and they then say, hit Run.
And they have their fingers crossed, and they're hoping they're like Scott and
it's all going to run.
>> [LAUGH] >> Except
then they're severely disappointed because, bam, an error comes up So
they heroically go through their 50 lines, and they look for that error.
And then they finally find it and they fix it.
And they hit Run again, and another error comes up.
And after they're found about the seventh or
eighth errors they start to get frustrated.
Because it's really hard to find those errors in a 50-line program.
And so the best piece of advice I have about testing is the following.
Don't write your code and then test.
Write a little bit of code.
Test.
Write a little bit of code.
Test.
Write a little bit of code.
Test.
That will keep the pain of testing down at a much more tractable level because if
your program is working and you write a couple of lines of code and
then a test fails, you know where the failure is.
It's in that few lines that you've written.
Now you might think, wow with all this testing its going to take me lots of time.
But remember, if you test as you go, what you'll see is,
that the time you spend on finding those errors is really reduced.
And so at the end of the day, testing will save you time.
>> I think that's an excellent point here, and I think that in this class we want to
take the philosophy where, were going to ease you into testing, that were going to
provide you with a bunch of tests that you can run on your own.
And that will help you sort of to solidify whether or not your program's actually
working and hopefully help you to debug your program as you go.
But we also want you to spend the time to think about writing tests on your own and
so we're going to provide you with some infrastructure to help you do
that as well.
And so hopefully between these two,
sort of, testing methodologies, we'll help ease you into the process of testing and
convince you that what we're saying is correct.
The testing is just as important as writing your code.
And that testing is something that should go on in parallel with writing your code,
not something you just do at the end.