1 / 9

2_Testing

2_Testing. Testing techniques. Testing. Crucial stage in the software development process. Significant portion of your time on testing for each programming exercise in this course. Testing ensures that the program that you are developing meets the requirements of the problem. Later

redford
Download Presentation

2_Testing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2_Testing Testing techniques

  2. Testing • Crucial stage in the software development process. • Significant portion of your time on testing for each programming exercise in this course. • Testing ensures that the program that you are developing meets the requirements of the problem. • Later • JUnit framework to perform one kind of testing called “unit testing.” • Exception for runtime faults • Testing allows you to detect bugs in your code. After a bug is identified, it must be fixed without introducing other bugs.

  3. Bug Types and Debugging Techniques • Syntax errors • A syntax error occurs when a program does not satisfy the grammatical rules of the programming language. For example, in Java, each declaration statement must end with a semi-colon. Forgetting it is a syntax error. Among other things, it is the role of the compiler to catch syntax errors. Therefore, such errors are the easiest to catch and fix. • Errors.java

  4. Bug Types and Debugging Techniques • Runtime errors • A runtime error occurs when the execution of the program terminates abnormally. Note that these errors manifest themselves at run time, not at compile time, which makes them more problematic than syntax errors. For example, an exception is raised when attempting to divide by zero.

  5. Bug Types and Debugging Techniques • Logic errors • A logic error exists every time the program does not behave the way it was supposed to, as specified in the requirements. These are the worst kind of errors because they are not caught by the compiler and they do not cause the program to crash. They may go undetected for a long time since they may manifest themselves only in a particular setting, e.g., for specific input values.

  6. Debugging • Debugging is the process of correcting errors in a program. • Use a combination of techniques for debugging: • Hand-trace the program • Insert ’print’ statements to keep track of which instructions are executed and what values variables take. 3. Use a software utility called a debugger to: • Set breakpoints • Execute your program one statement at a time • Display the value of variables and inspect the state of objects • Step into a method’s body or step over a method call • Inspect the call sequence • Pause (halt), resume, or terminate a long-running program

  7. Example: Counting syllables • One simple algorithm to count the number of syllables in a word: • count the number of vowel groups in the word, where a vowel group is a sequence of consecutive vowels that is surrounded by consonants on both sides or else appears at the beginning or the end of the word. • This algorithm works in most cases provided • silent e’s are removed from the end of the word, since they do not constitute a new syllable (e.g., in “niece” or “course”). • In addition, a vowel count of zero is treated as a count of one to account for words such as “the” that end in e and contain only one syllable.

  8. An FSM for a syllable-counter

More Related