levo

Testing an Object Oriented Application

Testing a class method by method

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

Overview

Exercising one method at a time with the object in a known state, checking what it returns and what it changes, and testing methods that depend on the order they are called in.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Evaluation

How is a setter that validates its argument tested?

Key term

How is a single method tested?

Key term

Which two things are examined after a method call?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    How is a single method tested?

    Model answer

    A method is tested by creating an object in a known state, calling the method with chosen arguments, and comparing both the value returned and the values the object then holds with what was expected.

  2. 2

    Which two things are examined after a method call?

    Model answer

    The value returned is examined, and the object's own attributes are examined through its accessors to confirm the method changed exactly what it was supposed to change.

  3. 3

    How is a method that returns nothing tested?

    Model answer

    A method returning nothing is tested by reading the object's state through its accessors afterwards, or by examining the effect it had on an object it was given.

  4. 4

    How is a getter tested?

    Model answer

    A getter is tested by creating an object holding a known value and confirming that the method hands that same value back unchanged.

  5. 5

    How is a setter that validates its argument tested?

    Model answer

    A setter is tested with a valid value that must be stored, with a value just outside the limit that must be refused, and with the value exactly on the limit to settle whether the limit is included.

  6. 6

    A setter accepts a percentage from 0 to 100, and a test calls setRate(100) and then getRate(). What result confirms the edge is handled correctly?

    Model answer

    The getter must hand back 100, which shows the value sitting on the upper limit was accepted rather than wrongly refused as too large.

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.