levo

Testing an Object Oriented Application

Testing constructors and object state

  • 3 things to know
  • AS Unit 1

Overview

Object's state and tested about an attribute the constructor never assigns.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Process

Why must a test examine the state after a sequence of calls rather than after one?

Key term

Why should a test check that two objects of the same class do not share data?

Key term

Why is a constructor tested separately from the other methods?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Why is a constructor tested separately from the other methods?

    Model answer

    A constructor settles the state every object begins in, so a fault there makes every later test unreliable and leaves every object wrong from the moment it exists.

  2. 2

    How is a constructor tested?

    Model answer

    An object is created with known arguments and every attribute is read back through the class's accessors to confirm that each was stored correctly.

  3. 3

    How is a constructor that rejects invalid arguments tested?

    Model answer

    The test supplies an unacceptable value and confirms that either no object is created or the fault is reported, so no object can exist holding that value.

  4. 4

    How are overloaded constructors tested?

    Model answer

    Each version is tested in its own right, because each takes a different set of arguments and each contains its own code for filling in the attributes it was not given.

  5. 5

    A one-argument Rectangle constructor is meant to build a square from a single side. What does the test check?

    Model answer

    The test creates the object with one value and confirms that reading the width and reading the height both give that same value.

  6. 6

    What is meant by an object's state?

    Model answer

    An object's state is the set of values its attributes hold at a given moment, and the state is what distinguishes one object of a class from another.

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.