levo

Testing an Object Oriented Application

Testing error handling paths

  • 3 things to know
  • AS Unit 1

Overview

Forcing each failure the code claims to handle, checking the exception is caught rather than escaping, that the message is useful, and that the object is left in a usable state afterwards.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Why must error handling be tested as thoroughly as the ordinary path?

Key term

A method converts typed text into a number. Which test proves it survives a non-numeric entry?

Key term

Why is testing with an empty file worthwhile?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Why must error handling be tested as thoroughly as the ordinary path?

    Model answer

    Error handling code runs only when something goes wrong, so a fault in it can lie unnoticed until the day it is needed, and that is the worst possible moment to discover it.

  2. 2

    How is a validation rule tested?

    Model answer

    The rule is tested by supplying a value it must refuse and confirming that the value was not stored and that the program reported the problem instead.

  3. 3

    How is a handler tested?

    Model answer

    The test supplies data that forces the fault the handler was written for, then confirms the program produced the intended message and carried on rather than stopping.

  4. 4

    A method converts typed text into a number. Which test proves it survives a non-numeric entry?

    Model answer

    The test enters a word instead of a number and confirms the program reports the entry as invalid and asks again, rather than halting with an untrapped fault.

  5. 5

    How is a file-reading method tested for a missing file?

    Model answer

    The test names a file that does not exist and confirms the method reports the problem and returns control, rather than terminating the whole program.

  6. 6

    Why is testing with an empty file worthwhile?

    Model answer

    A file holding no records exercises the case in which the reading loop never runs at all, and code that assumes at least one record often produces a wrong total or fails outright.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Testing an Object Oriented Application, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.