Testing This is the first video of lecture 11. This lecture will cover testing and debugging code in MATLAB. Motivate testing with example. Walk through what the code does. Point out code for testing password too, use 's' in input to get string, and use isletter to test the first entry (isletter tests a single character) Should build a test suite - set of tests that cover many different aspects of the code (such as many different input values) Test coverage: Want to make sure that each line of code is executed by at least one test Positive test cases - "Good input", intended execution Negative test cases - "Bad input", unexpected input Corner test cases - edge cases between good and bad Demo different input on the id and password example. Will need something similar for homework 6. Remember, input takes MATLAB expressions, so we need to be careful that we are working with a scalar number. Examples (for ID validation): -1234567 -123abc -No input (just hit enter) -1234567.8 -Vector of numbers ([1,2]) -'hello' Testing showed us a lot of problems. How can we fix these? -1234567, fine and working as intended -123abc, invalid MATLAB expression, we can ignore this case for now -No input, gives a 0x0 matrix, can check length(id)==1 -1234567.8, check for integer using mod(id,1)==0 -Vector of numbers, can check length(id)==1 -String (or character), check if value is a number using isnumeric Note, you won't need as exhaustive of checks for homework 6. Making a Test Suite (video 2): Walk through how validateID was made a function and how to use it in the same was as in the script. Reminder from the last lecture: a test suite should cover Walk through test cases. Show how the output changes when the function changes. Purposely break a test case that causes an error. Show try catch functionality. Use err.message to display the error to the user. Mention this can be used in the rest of their code, not just reserved for testing!