Title: Previous test problem 1 midterm, S06
1Previous test problem 1 midterm, S06
- Create a test sequence (events expected
responses) that covers all transitions for this
state diagram.
2Previous Test Problem 2 midterm S06
- For this state diagram, assume that tests should
start and end in state A. - Determine an event / response sequence that can
be used for - a) a preamble to state D
- b) a postamble to state D
- c) a state verification sequence for state D.
3Previous test problem 3 midterm S06
- What is the difference between a defect and a
failure? Is it always the case that one defect
is associated with one failure? Why or why not?
4Previous test problem 4 midterm S06
- What are the two factors that contribute to risk?
5Previous Test Problem 5 exam S06
- At which phase of the development process would
each of the following statements be valid? - a) defects are most likely to be introduced
- b) defects require the most effort to be fixed
- c) defects are the most costly to detect.
6Previous Test Problem 6 Exam S06
- Suppose that you have a non-trivial software
program. Why is it impossible to test the
program completely?
7Previous Test Problem 7 Exam S06
- The input to this method is two polynomials,
stored as an array of integer coefficients where
polyi is the coefficient of xi. For example,
if there is a term axi in the polynomial, the
value of polyi would be a. - The output from the method is the sum of the two
polynomials, stored as an array of integer
coefficients. The two input polynomials may have
different numbers of coefficients. In addition,
the result polynomial must not have zero as the
leading coefficient. - Draw a control flow graph for this method
(continued on next 2 slides). -
- public static int addPolynomials( int poly1,
int poly2 ) -
- int result // Result polynomial.
- int longPoly // Reference to input poly.
with larger degree - int shortPoly // Reference to input poly.
With smaller degree - int resultSize // Index of largest
coefficient of result. - int bothIndex // Index at which both
input polys. have coefs. - int index // Loop index
-
8Part 2 of method
- result null // If null input, return null
result. - if ( poly1 ! null poly2 ! null ) //
Ensure non-null input -
- if ( poly1.length lt poly2.length ) // Check
polynomial degrees -
- longPoly poly2 // Polynomial 2 has
higher degree - shortPoly poly1
-
- else
-
- longPoly poly1 // Polynomial 1 has
higher degree - shortPoly poly2
-
- resultSize longPoly.length - 1 //
Tentative degree of result - bothIndex shortPoly.length - 1 // Index
to start adding coefs. - if ( poly1.length poly2.length )
-
- while ( poly1resultSize
poly2resultSize 0 ) -
9Part 3 of method
- result new intresultSize 1 // Create
result array. - index resultSize // Start at
highest index - while ( index gt bothIndex )
-
- resultindex longPolyindex // Copy
coefs. of higher - index index - 1 //
degree poly. -
- while ( index gt 0 ) // Add coefs. where
both exist. -
- resultindex longPolyindex
shortPolyindex - index index - 1
-
-
- return result
-
- When creating the flow graph, number the
branches.
10Previous Test Problem 8 exam S06
- For the method in the previous problem (i.e.
polynomial addition), create a set of test cases
that meet the branch coverage criterion.
11Previous test problem 9 Exam S06
- If a set of test cases meets the multiple
condition coverage criterion, what must be
covered by the test cases?
12Metro train scenario Exam S06
- For a metro train control system, the signal
lights warn of trains ahead. The track is
divided into blocks to keep the trains at a
safe distance from each other. Trains cannot be
in two consecutive blocks simultaneously. - A red signal indicates that there is another
train in the block immediately ahead of the
signal. A yellow signal indicates that the block
ahead is clear, but that there is another train
in the second block ahead. A green signal
indicates that the two blocks ahead are both
clear.
13Metro train scenario, part 2
- A train must stop behind a red signal, but can
proceed slowly if the signal is yellow and can
proceed at full speed if the signal is green.
When a train passes a signal that is green or
yellow, the signal changes to red. - To ensure that trains do not pass red signals, a
safety bar mechanism is used. If the safety bar
is at track level, a train can pass by. However,
if the bar is raised about 30 cm, the bar will
hit a switch on a passing train that will cut off
power to the trains engine and the emergency
brakes will be activated. The bar should be
raised whenever the signal is red, and lowered
for signals of any other colour. If a train
passes a red signal, an alarm is also activated.
14Metro train scenario, part 3
- Below is a state machine for the metro train
signal lights. The inputs are train,
indicating that a train is passing the signal
light, Exit block 1 which occurs when a train
leaves the block just ahead of the signal, and
Exit block 2 which occurs when a train leaves
the second block ahead of the signal.
15Previous test problem 10 Exam S06
- The metro signal light is a safety-critical
system and it should be established that
unexpected events do not cause a problem. List
the state and event combinations that are not
covered in the state machine.
16Previous test problem 11 Exam S06
- Complete the following table for the metro train
state machine.
17Previous test problem 12 exam S06
- Create a set of conformance tests for the metro
train state machine. - For each test case, include
- an ID number
- the event and response sequence
- identify the test purpose
- example test transition from yellow to green
check state verification for state red, etc.
18Other topics?
- New in this terms course
- Data flow graphs
- Data flow coverage
- Call graphs
- Material on last years midterm, but still to
come for this terms course - Equivalence class partitioning
- Standards, documentation, etc.
19GST credit scenario Exam S06
- For a family consisting of two people living as
spouses or common-law, the Canada Revenue Agency
determines eligibility for the goods and services
tax credit based on the family income and the
number of children. - You are assigned to test a web page GST credit
calculator for small families that have 0, 1,
or 2 children. Families with 3 or more children
should be redirected to the larger family web
page. - The user will enter the family income and the
number of children in two text entry fields. If
the income cannot be parsed as a number, or is
negative, an incorrect input web page should be
displayed. If the number of children cannot be
parsed as an integer, or is negative, the
incorrect input web page should be displayed.
20GST credit scenario, part 2
- The result will be specified as full credit,
partial credit, or no credit. - The criteria are as follows for the period from
July 2005 to June 2006 - If the family income is 29,618 or less, the full
credit is given, regardless of the number of
children. - Partial credit is given for incomes over 29,618
depending on the number of children. The maximum
incomes to receive partial credit are - 0 children 38,698
- 1 child 41,098
- 2 children 43,498
- No credit is given for incomes above the maximum.
21GST credit scenario, part 2
- The result will be specified as full credit,
partial credit, or no credit. - The criteria are as follows for the period from
July 2005 to June 2006 - If the family income is 29,618 or less, the full
credit is given, regardless of the number of
children. - Partial credit is given for incomes over 29,618
depending on the number of children. The maximum
incomes to receive partial credit are - 0 children 38,698
- 1 child 41,098
- 2 children 43,498
- No credit is given for incomes above the maximum.
22Previous test problem 13
- Determine a set of valid and invalid equivalence
classes for the GST credit scenario.
23Previous test problem 14
- Derive a set of test cases from your set of
equivalence classes for the GST scenario.
Identify which classes are covered by each test
case. Within the test cases, be sure to include
the expected responses for type of GST credit,
and any other response.