levo

Testing an Object Oriented Application

Testing a class method by method

  • 3 things to know
  • AS Unit 1

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.

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.