Slides badge

Testing

Learning Intentions

  • Describe, identify exemplify and use normal, extreme and exceptional test data
  • Develop and understand test plans and how to use them
  • Understand the different types of errors that occur in programming

Success Criteria

  • Be able to create test data and explain why it is needed
  • Be able to identify errors and identify the cause of them

Testing

  • Test data is a set of data that is used to test a program.
  • We create test data because we cannot test every possible set of test data (this is called computational impossible).
  • There are three kinds of test data, Normal, Extreme and Exceptional
  • We can create a test table which contains the values to be tested in each of the above categories.

Types of test data

  • Normal test data is data well within the boundaries given. The program is expected to continue to run as expected.
  • Extreme data is on the very boundaries, still within the boundaries, of what is expected to work.
  • Exceptional data will cause the program to stop working as expected.

Test plan

  • A program that is expected to check if the user is under the age of 80 and over the age of 50 is written in Python.
print("Please insert your age")
age = int(input())

if age > 50 and age < 80:
  print("Working okay")
else:
  print("Not valid")

Test plan

  • A program that is expected to check if the user is under the age of 80 and over the age of 50 is written in Python.
print("Please insert your age")
age = int(input())

if age > 50 and age < 80:
  print("Working okay")
else:
  print("Not valid")
Type Examples Expected result Actual result
Normal 57, 64 Program works as expected Program works as expected
Extreme 79, 51 Program works as expected Program works as expected
Exceptional 84, 94, -3, 46, "John" Program stops working Program stops working

Test data

  • Test data is the type of data we will use to test our programs.
  • There are three kinds of test data:
    • Normal
    • Extreme
    • Exceptional

In computer science and programming, an exception is similar to an error except that unlike errors, exceptions are normally (but not always) recoverable from. Exceptions tend to change the flow of a program whereas errors tend to crash the program.

Test tables

  • A test table for a program to accept numbers between 1 and 60 inclusive is shown. Notice that 1 and 60 are not accepted so the table shows that this test does not pass.
Type Examples Expected result Data accepted? Passed?
Normal 25 Accepted Yes Yes
Normal 53 Accepted Yes Yes
Extreme 1 Accepted No No
Extreme 59 Accepted No No
Exceptional 60 Not accepted No Yes
Exceptional Bob Not accepted No Yes

Test tables

A program is written to take in test scores in percentages between 1 and 100.

 

  1. Identify normal data for this program
  2. Identify extreme data for this program
  3. Identify exceptional data for this program

Try it yourself

Errors

  • There are three types of errors you need to know about at National 5:
    • Syntax
    • Logic
    • Runtime errors

Syntax errors

  • Syntax errors occur when the program contains something that it doesn't recognise. 
  • Syntax errors occur when something is written that breaks the syntax rules of the programming language. The program cannot run as a result of a syntax error.
  • Syntax errors are discovered by the compiler or interpreter rather than during runtime.
  • Common syntax errors include:
    • Misspelling a word
    • Forgetting a colon
    • Forgetting a bracket
    • Forgetting quote marks
    • Incorrect indentation 

Logic errors

  • Logic errors occur when the logic or mathematical sums aren't correctly written. 
  • For example:
    • average = mark1 + mark2 + mark3 / 3
    • is not the same as
    • average = (mark1 + mark2 + mark3) / 3
  • The most common logic error tends to be when using And and Or and getting them muddled up. The other very common cause for logic errors is with > and <, as well as >= and <=.

Runtime errors

  • Runtime errors occur when the program is running. 
  • They are not often easily identifiable.
  • Runtime errors will crash the program, but only when (and if) the error is reached.
  • The most common types of runtime errors are:
    • Division by 0
    • Not declaring a variable before using it (only in interpreted programs like Python)
    • Accessing an array element passed the end of the array

Plenary

Pick up to 4 key words and provide a description for them.

Logic error

Runtime error

Normal test data

Extreme test data

Syntax error

Exceptional test data

Presentation Overview
Close
JB
Testing
© 2020 - 2024 J Balfour
22:55 | 12-04-2024
Join Live Session
Start Remote
Save Progress
Slideshow Outline
Presenter Mode
Widget Screen
Canvas Controls
Random Selector
Timer
Volume Meter
Binary Converter
Python Editor
Show Knox 90
Provide Feedback
Help
!
Keywords
    DragonDocs Management
    Random selector
    Sections
      Binary conversion
      Denary to binary conversion
      Binary to denary conversion
      Feedback 👍
      Accessibility

      Apply a filter:

      ×
      All slideshow files