Return to Video

06-23 Code Coverage

  • 0:00 - 0:03
    We've seen a little bit of testing, but let's look at testing from another angle.
  • 0:03 - 0:07
    Let's say this is the program or the thing that we're considering testing.
  • 0:07 - 0:10
    We want to test our JavaScript interpreter,
  • 0:10 - 0:15
    and we're going to feed it this factorial definition and this call to document write.
  • 0:15 - 0:21
    And by thinking hard about the problem, we know the answer we should get is 120.
  • 0:21 - 0:24
    5 times 4 times 3 times 2 times 1--5 factorial.
  • 0:24 - 0:26
    Here's the quiz.
  • 0:26 - 0:29
    Let's say this is our test case and that's the input we're comparing against.
  • 0:29 - 0:33
    I want to know which parts of the program we gain confidence about.
  • 0:33 - 0:37
    So here I've written 6 important parts of our JavaScript interpreter:
  • 0:37 - 0:42
    handling function calls; handling environment lookups for variable values;
  • 0:42 - 0:47
    handling string constants like hello; local variable declarations like var temp = 3;
  • 0:47 - 0:52
    assignment statements like z = 2; and binary operations like addition.
  • 0:52 - 0:56
    And what I want to know is, if this is our test input
  • 0:56 - 0:59
    and we're comparing the answer to 120,
  • 0:59 - 1:02
    which of these features in our interpreter will be tested?
  • 1:02 - 1:05
    If something isn't tested, we can't hope to find a bug in it.
  • 1:05 - 1:08
    As a hint, another way of looking at this problem is to imagine,
  • 1:08 - 1:13
    let's say, that our code for function calls totally didn't work.
  • 1:13 - 1:16
    Would we get 120?
  • 1:16 -
    If the answer is no, then we're testing function calls.
Title:
06-23 Code Coverage
Description:

Other units in this course below:
Unit 1:http://www.youtube.com/playlist?list=PL3FEF9299137945CC
Unit 2:http://www.youtube.com/playlist?list=PLBF6FC32358457242
Unit 3:http://www.youtube.com/playlist?list=PL30EF9EB86B4D2E54
Unit 4:http://www.youtube.com/playlist?list=PL6881C8D2E9D63242
Unit 5:http://www.youtube.com/playlist?list=PL62AF1F6D3B654E14
Unit 6:http://www.youtube.com/playlist?list=PL8FCC9D9C45A6640E
Unit 7:http://www.youtube.com/playlist?list=PL9533BCB71FD88E38

Q&A: http://www.youtube.com/playlist?list=PLE0EB375FA373A866

To gain access to interactive quizzes, homework, programming assignments and a helpful community, join the class at http://www.udacity.com

more » « less
Video Language:
English
Team:
Udacity
Project:
CS262 - Programming Languages
Duration:
01:20
Amara Bot added a translation

English subtitles

Revisions