1/78
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is path testing?
Path testing is concerned with test cases that cause chosen paths through a program to be executed, primarily for component testing, requiring knowledge of the source code.
What determines a program's execution paths?
Paths depend on criteria like data input values, with statement execution influenced by prior statements.
What is the bug assumption in path testing?
The program makes the right decision at the wrong time or the wrong decision at the right time, taking the wrong path.
Give an example of defective code in path testing.
IF X > 0 THEN instead of IF X < 0 THEN.
What is "sensitising the path"?
Choosing input values to force a specific path's execution, often challenging in complex code.
What are the main coverage techniques?
Statement coverage and branch coverage.
Define statement coverage.
Ensures every executable statement is executed at least once.
Define branch coverage.
Ensures every outcome of every decision is executed at least once.
How is statement coverage measured?
(statements executed / total statements) * 100.
What is the easiest coverage to achieve?
Statement coverage.
What is the procedure's first step for statement testing?
Identify all executable statements.
What counts as an executable statement?
Statements that "do something" (e.g., print), not data definitions or ELSEs.
Calculate statement coverage for A=5, B=2 in if A > B then Print... else Print....
5/7 * 100 = 71.00%.
What is decision coverage's goal?
To cover all true/false outcomes of decisions.
What ensures path coverage?
Covering all paths from start to end.
What is source code debugging, and what tool is used?
A process in an IDE to investigate defects, using the IDLE debugger.
How does debugging differ from unit testing?
Debugging investigates defects, while unit testing verifies functionality.
What defect arises from mismatched programmer expectations?
A defect where the programmer's expectation doesn't match program execution.
Why is debugging challenging?
Lines execute quickly, and variable values change frequently.
How does a debugger help?
Steps through code line by line and shows variable values.
How can debugging be sped up?
Jump to specific code of interest instead of stepping through every line.
What does PyUnit advocate the idea of?
First testing then coding
What is Debugging?
Process of identifying and correcting logic errors.
What are the initial investigation options for defects in code, and their limitation?
Visual review and print statements; limitation is time-consuming with large code.
How do you access the IDLE Debugger?
Select "Debug" > "Debugger" in the Python Shell.
Name the five IDLE Debugger options.
Go, Step, Over, Out, Quit.
What does "Step" do in the debugger?
Steps one instruction, entering function calls.
What does “Go” do in the debugger?
Resume until breakpoint/end
What does “Over” do in the debugger?
Steps one instruction, doesn’t enter function calls but steps over them.
Debugger's power
Efficiently identifying and fixing defects.
Defects detected by compilers
Syntax errors, undeclared variables, unreachable code, etc.
What are modern compilers in defect detection
Data flow analysis and Control flow analysis.
Data flow analysis concern
How data is used on different code paths.
Three data variable states
Undefined (u), Defined (d), Referenced (r).
What can Data Flow Analysis do?
Identifies anomalies.
Ur-anomaly
Reading an undefined data item.
Du-anomaly
A defined item becomes undefined without use.
Dd-anomaly
Reassigning a defined item without using it.
What is the starting point of Path Testing?
Program flow graph that shows nodes representing program decisions and arcs representing the flow of control
Anomalies in FactorialExample
No explicit anomalies, but check n, counter, result usage.
Program flow graph description
Program control flow, with branches and loops.
Path testing objective
Ensure test cases execute desired paths at least once.
Flowgraph primitives
Decision, junction, process block.
Definition of a path
A sequence from entry/junction/decision to another, possibly repeating.
Complete path
A path from routine entry to exit.
Unit test tips
Provide meaningful or accurate messages in assert statements
Unit testing effect on debugging
Reduces debugging time if implemented correctly.
Purpose of unit tests
To verify code logic and detect regressions.
Other testing supported by unit frameworks
Integration and system-level testing.
What is PyUnit
A testing framework that enables us to quickly develop, execute and re-execute unit test cases for python code
What happens when Unit test fails for an individual programmer
Compilation fails until it passes.
What happens when a Unit test fails for a group of programmers
Group build fails, embarrassing the breaker.
Continuous Integration (CI)
Frequent code integration with automated builds.
CI benefit for error detection
Detects errors quickly and easily.
Characterization of a PyUnit test case
Known input and expected output.
Test cases per requirement
At least two: one positive, one negative.
What is a PyUnit Test case?
A piece of code that checks that another piece of code works as expected
Two PyUnit assertions
assertEqual(a, b) (a = b), assertNotEqual(a, b) (a != b).
What is Continuous Integration?
A development practice that requires developers to integrate code into a shared repository several times a day
What is the location debate for unit tests
Some advocate shipping unit test code to production systems, Some don’t.
What does “Out” do in the debugger?
Keeps stepping over lines of code until the debugger leaves the function it was in when Out was clicked.
What does “Quit” do in debugging
Terminates the program.
What is a breakpoint in debugging?
A marker set by the programmer that temporarily halts program execution at a specified line of code.
What is a decision
program point at which the control can diverge (if and case statements)
What is a junction?
Program point where the control flow can merge. (end if, end loop)
What is a process block?
A sequence of program statements uninterrupted by either decisions or junctions
Unit Test Lifecycle
Write test code, Compile test code., Write/modify unit code, Compile code, Execute tests, Compare results, Iterate.
What is Data Flow Analysis
Static analysis method to understand how variables are used and focuses on identifying improper use of data, e.g., using a variable before it's defined.
Undefined
Variable has no value
Defined
Value has been assigned
Referenced
Value Used
What is a Control Flow Graph
visually maps all control paths through a program
What is a positive test?
Confirms expected output for valid input.
What is a Negative test?
Confirms correct handling of invalid input or errors.
What is a Test Suite?
Combine multiple test classes and Enable batch test execution
What do Continuous Integration systems do?
Running tests on commit and Flag regressions early
CFG vs DFA
CFG shows control flow and the different paths a program can take as it runs while DFA detects data anomalies and shows how data is used and moved around.
Procedure for Statement Testing
Identify executable statements.
Trace execution from the first statement.
Choose the true outcome initially for decisions, noting variables.
Continue until all statements are covered by tests.
Document variable values needed for each execution path.
Test-Driven Development
test setup → test → code → unit test