Presentation is loading. Please wait.

Presentation is loading. Please wait.

2_Testing Testing techniques.

Similar presentations


Presentation on theme: "2_Testing Testing techniques."— 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
Event state vowel not a vowel Not in VG In VG (count++) In VG

9


Download ppt "2_Testing Testing techniques."

Similar presentations


Ads by Google