levo

Testing an Object Oriented Application

Testing error handling paths

  • 3 things to know
  • AS Unit 1
Start revising · £5/month

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.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

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

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A null is the of one.
absencepresencetype

Blank Blitz consolidates the facts

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

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

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.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

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