Test 2 Flashcards
What are the 6 requirements for the following functionality coverage test:
“Given as input two integers x and y, output all the numbers smaller than
or equal to x that are evenly divisible by y. If either x or y is zero, then
output zero.”
“Given as input two integers x and y”
R1. Accept two integers as input.
“output … the numbers”
R2. Output zero or more (integer) numbers.
“smaller than or equal to x”
R3. All numbers output must be less than or equal to the first input
number.
“evenly divisible by y”
R4. All numbers output must be evenly divisible by the second number.
“all the numbers”
R5. Output must contain all numbers that meet both R3 and R4.
“If either x or y is zero, then output zero.”
R6. Output must be zero (only) in the case where either first or second
input integer is zero.
Is Functionality Coverage testing systematic? Explain.
Yes, we have a system for creating tests, it tells us when we are done.
What are the guidelines for choosing test inputs in black box testing.
(1) Consistently choosing the simplest input values possible, in order not
to introduce arbitrary variations
(2) Keeping everything constant between test cases, varying only one
input value at a time (don’t try to be “clever” introducing random input
variations)
These hold for all systematic test methods.
Name the 3 types of Black Box Methods.
- input coverage tests, which are based on an analysis of the intended
inputs, independent of their actions or outputs - output coverage tests, which are based on an analysis of the intended
outputs, independent of their inputs or actions - functionality coverage tests, which are based on an analysis of the
intended actions, with or without their inputs and outputs
Name 4 Input Coverage Tests.
exhaustive, (input) partitioning, shotgun, (robustness) boundary
What is Exhaustive Testing?
▪ Involves testing the program with every possible input – yields a strong
result: virtually certain that the program is correct
▪ Easy system for test cases, and obvious when done
▪ But usually impractical, even for very small programs
What is Input Partition Testing?
Partition all the possible inputs into equivalence classes
which characterize sets of inputs with something in common.
List all relevant partitions for the following input partition test:
“Given as input two integers x and y, output all the numbers smaller than or
equal to x that are evenly divisible by y. If either x or y is zero, then output
zero.”
What numbers would we use?
Partition: x input, y input
P1: 0, non-zero
P2: non-zero, 0
P3: 0, 0
P4: less than zero, less than zero
P5: less than zero, greater than zero
P6: greater than zero, less than zero
P7: greater than zero, greater than zero
-1, 0, 1
Advantages of Input Partition Testing?
intuitively
easy to identify a set of partitions given the functional
specification
easy to say when we are done
confidence that the program is at least capable of handling (one
example of) each different kind of input correctly
What is Shotgun Testing
Black box shotgun testing consists of choosing random values for inputs
(with or without worrying about legality) over a large number of test runs
▪ We then verify that the outputs are correct for the legal inputs, and that
program simply did not crash for illegal ones
▪ More practically, we usually choose inputs from the legal set and inputs from
the illegal set as separate sets of shotgun tests
Is Shot Gun Testing Systematic?
No, there is a system for choosing test cases (i.e. randomly), but there are no completion criteria (we don’t know when we are done).
What is Boundary testing?
testing checks for crashes on unexpected or unusual input, such
as the boundaries of the input range.
What is Exhaustive Output Testing
▪ Exhaustive output testing makes one test for every possible output
▪ Practical more often than exhaustive input testing, because programs are
often written to reduce or summarize input data (like the previous example)
▪ But still impractical in general - most programs have an infinite number of
different possible outputs
What testing is best used for this problem “Output 1 if two input integers are
equal, 0 otherwise”
Output testing because there is only two cases.
What is Output Partition Testing?
Output partitioning is like input partitioning, only we analyze the possible
outputs
▪ In a fashion similar to input partitioning, we partition all the possible outputs
into a set of equivalence classes which have something in common
Difference between Black Box Testing and White Box Testing?
Black: Uses specifications not code
White: Uses code
What is the system for creating block-based coverage?
Identify basic blocks by sequence analysis then design a test case for each basic block.
We make a test case for each block to analyze which inputs are needed to cause the block to be entered.
What is Decision Coverage
Causes every decision (if, switch, while, etc.) in the program
to be made both ways (or every possible way for switch)
* System: Design a test case to exercise each decision in the
program each way (true / false)
* Completion criterion: A test case for each side of each decision
Whats is Loop Coverage?
This method makes tests to exercise each loop in the program
in four different states :
- execute body zero times (do not enter loop)
- execute body once (i.e., do not repeat)
- execute body twice (i.e., repeat once)
- execute body many times
System: Devise test cases to exercise each loop with zero, one,
two and many repetitions
* Completion criterion: A test for each of these cases for each loop
What is Execution Paths?
An execution path is a sequence of executed statements
starting at the entry to the unit (usually the first statement)
and ending at the exit from the unit (usually the last statement)
* Two paths are independent if there is at least one statement on
one path which is not executed on the other
* Path analysis (also know as cyclomatic complexity* analysis)
identifies all the independent paths through a unit
What is cyclomatic complexity?
E - N + 2
E: # of Edges
N: # of Nodes
Advantages of Path Coverage Testing?
- Covers all basic blocks (does all of basic block testing)
- Covers all conditions (does all of decision/condition testing)
- Does all of both, but with fewer tests!
- Can be automated (actually, in practice requires automation)
Disadvantages of Path Coverage Testing?
Does not take data complexity into account at all
For Data Flow Coverage define: P-Use, C-Use, Definition
A P-use of a variable is a predicate use (e.g. if statement)
* A C-use of a variable is a computation use or any other use
(e.g. I/O statements)
A variable is defined if it is assigned a new value during a
statement execution