introduction to testing csis 1595: fundamentals of programming and problem solving 1

6
Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1

Upload: mark-blair

Post on 18-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1

Introduction to Testing

CSIS 1595: Fundamentals of Programming and Problem Solving 1

Page 2: Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1

What is Program Correctness?

• Program produces correct output for all possible inputs

• Requires you to know what correct output is• Impossible to assure in practice– Cannot test program with all possible input in all possible

situations

Page 3: Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1

Types of Errors

• Syntax errors: Code that cannot be understood by interpreter/compiler

• Run time errors:Code that causes program to “crash” when run

• Logic errors:Code runs, but does not produce correct output for some input– Hardest to find and fix!

Page 4: Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1

Program Testing

• Done with test cases– Input to program– Expected output of program– If actual output ≠ expected output, logic error

• Example:– Input: 3.6, 9.2– Expected output: 6.4

Page 5: Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1

Program Testing

1. Design input of case – What are you testing?

2. Compute expected output– Know what program should do before performing the test

3. Perform test– Compare actual result to expected result

4. Debug program– Modify program so actual result = expected result

Page 6: Introduction to Testing CSIS 1595: Fundamentals of Programming and Problem Solving 1

Good Testing

• Attitude: running program with goal of finding errors– Successful test finds error

• Test cases created in advance– Done before writing program

• Testing done continuously– Test during program after new code added– Test after each change to program as part of debugging