identify concepts: | done |
associations: | done |
attributes: | done |
glossary: | done |
sequence diagrams: | today |
contracts: | today |
(chapter 13)
When actors interact with system, they generate events to a system. These events require an operation by the system in response.
Sequence diagrams are used to illustrate the system operations and the actors who initiate them.
They are sequence
diagrams - the events are in (time) order.
And they are tied to a
use case.
The system is still treated as a black box |
Actor Action |
System Response |
---|---|
Use case begins when a Customer arrives at POST checkout with items to buy. |
|
Cashier records identifier of each item. If several of same item, Cashier can enter quantity. |
Determines item price and adds item info to transaction. Description and price of current item presented. |
On completion of item entry, Cashier tells POST that item entry is complete. |
Calculates and presents the sale total. |
Cashier tells Customer the total. |
|
Customer gives Cashier at least enough cash. |
|
Cashier records the cash received amount. |
Shows change to be given to customer. Generates a receipt. |
Cashier deposits cash received and extracts balance. Cashier gives change and receipt to Customer. |
Logs the completed sale. |
Customer leaves with items purchased. |
|
external input event generated by an actor
initiates a responding operation by system
operation the system executes in response to system event
Draw a line representing the system as a black box.
Identify each actor that directly operates on the system. Draw a line for each such actor.
From the use case typical course of events text, identify the system (external) events that each actor generates. They will correspond to an entry in the rhs of the typical use case. Illustrate them on the diagram.
Optionally, include the use case text to the left of the diagram.
UML has a type
System for recording system operations
may include
parameters
should be expressed as intent rather than physical input medium or widget
start with a verb
aim for highest level of intent
Contracts describe system behaviour
(Contracts will be applied to class methods later.)
Contracts are expressed using preconditions and postconditions.
Preconditions and postconditions are assertions.
they will be implemented as boolean expressions
assertions about
state of system
value of arguments
which are necessary for an operation to take place.
assertions about
state of system
(later) return value
which are necessary
if an operation has been successful.
That is, if it has done what
it is supposed to do.
Contract | |
---|---|
Name |
enterItem
upc : text |
Responsibilities |
Enter (record) sale of an item and
add it to the sale. |
Cross references |
Buy items use case |
Notes |
|
Output |
|
Preconditions |
UPC is valid; Qty > 0 UPC is known to system |
Postconditions |
If a new sale, a Sale was created If a new sale, the new Sale was associated with the POST A SaleLineItem was created The SaleLineItem was associated with the Sale SaleLineItem.quantity was set to quantity The SaleLineItem was associated with a ProductSpecification, based on UPC match |
Contract | |
---|---|
Name |
Name of operation + parameters |
Responsibilities |
Informal description of the responsibilities of the operation. |
Cross references |
System function reference numbers, use cases. |
Notes |
Anything helpful (eg suggested algorithm) |
Output |
Non user interface output, such as messages sent out of system. |
Most important are preconditions and postconditions.
If when a pre or post condition is not met there is a bug in the system and an exception should be raised. We will discuss this further later.
Name and parameters from system sequence diagrams.
Write Responsibilites section.
Postconditions
Preconditions
Types of postconditions
Assertions
(Somerville, chapter 22 + other material)
Verification and Validation. checking process that ensures software conforms to specifications
The key is the contracts
A class is tested in isolation
Software components and / or hardware components are combined and tested to evaluate the interaction between them.
Should be incremental.
Leads to sub-system testing. Most common problems are interface problems.
Leads to system testing. Interaction between sub-systems. System must meet functional and non-functional requirements.
Testing with data supplied by customer
Probably by customer.
Aside
Acceptance testing is sometimes called alpha testing. Typically a single customer.If software being sold on the open market, can use beta testing. Deliver system to a number of potential customers who agree to use it.
See also "The Cathedral and the Bazaar".
White box testing and black box testing
Tester knows the code
Make up test
cases based on execution paths in the code
cover all
statements,
cover all branches,
cover all paths.
Covering
all paths very good but there may be many paths.
Inspections
and walkthroughs.
Manual or computer assisted (CASE tools)
Can
be efficient at finding bugs early.
Someone other than author
should be involved.
Relies solely on specifications.
Generate data
Tester and writer distinct.
Everyone has an understudy
Simplest way is to use a debugger or lots of printlns.
Computer assisted is better: Use a test framework.
Each component should be tested.
Test data derived from contracts.
Test data constructed by someone other than the writer of the component.
Component should
satisfy test data after writing
and after every change.
So...
testing should be computer assisted and as automated as possible.
operation: | deposit $5 |
object(s): | account with $10 |
outcome: | account with $15 |
Collection of concrete and abstract classes and the interface between them.
Semi-finished software architecture.
A template
When completed they often become subsystems.
They are completed by writing concrete descendants of the abstract classes.
eg. framework for cgi scripts (web applications).
Test framework for Java written by Kent Beck and Erich Gamma.
ftp://www.armaties.com/TestingFramework/JUnit/
public void testSimpleAdd { Dollars d10 = new Dollars(10); Dollars d12 = new Dollars(12); Dollars expected = new Dollars(22); Dollars result = d10.add(d12); assert(expected.equals(result); } // testSimpleAdd
Tests need to be
run against a set of known objects.
This set of objects is called
a fixture.
(Spend more time writing code to set up fixtures
than in actual testing.)
Run a test case against a fixture.
Run several test cases at once.
Allows tester to specify which suites to run.