English subtitles

← 03-13 Testing Coverage

03-13 Testing Coverage

Get Embed Code
1 Language

Showing Revision 2 created 07/16/2014 by Udacity Robot.

  1. So on the subject of statement coverage, we will take a very short quiz.
  2. The quiz is going to have two parts, both of which
  3. stem from a little statistics module that we have here.
  4. The function stats is defined to take a list of inputs and what the function does is
  5. computes the smallest element in the list, the largest element in the list, the median element of the list--
  6. that is to say if we order the list numerically the middle element where the average of the two
  7. middle elements if the list has an even number of elements and finally, it computes the mode of the list
  8. where the mode is the element which occurs the most frequently in the list.
  9. In the case where the list is bimodal--meaning it has two modes or
  10. multimodal--more than two modes--we'll print all of it.
  11. What we do here is test the stats function extremely badly, so I'm going to create a list containing
  12. only the #31 and I'm going to call stats on the list and so let's look at the coverage that we get.
  13. We can see here that even my fairly bad test managed to cover 29 statements in
  14. the stats function but these statements are uncovered and it's shown right here.
  15. Your assignment for the first part of this API quiz is to--early collection
  16. of test cases for it which is 100% statement coverage.
  17. What I mean by that specifically is that your job is to construct a several lists,
  18. calls stats on them, and cover all statements.
  19. What I'd like you to do is think about it a little bit, try to visualize the effect that your inputs
  20. are having on the code, try to come up with the corruption of inputs that gets false
  21. statement coverage on the first try but then, of course, check your answer using the coverage tool.