levo

Testing an Object Oriented Application

Testing constructors and object state

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

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.

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.