Path Testing, Debugging, and Unit Testing Overview

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/78

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

79 Terms

1
New cards

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.

2
New cards

What determines a program's execution paths?

Paths depend on criteria like data input values, with statement execution influenced by prior statements.

3
New cards

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.

4
New cards

Give an example of defective code in path testing.

IF X > 0 THEN instead of IF X < 0 THEN.

5
New cards

What is "sensitising the path"?

Choosing input values to force a specific path's execution, often challenging in complex code.

6
New cards

What are the main coverage techniques?

Statement coverage and branch coverage.

7
New cards

Define statement coverage.

Ensures every executable statement is executed at least once.

8
New cards

Define branch coverage.

Ensures every outcome of every decision is executed at least once.

9
New cards

How is statement coverage measured?

(statements executed / total statements) * 100.

10
New cards

What is the easiest coverage to achieve?

Statement coverage.

11
New cards

What is the procedure's first step for statement testing?

Identify all executable statements.

12
New cards

What counts as an executable statement?

Statements that "do something" (e.g., print), not data definitions or ELSEs.

13
New cards

Calculate statement coverage for A=5, B=2 in if A > B then Print... else Print....

5/7 * 100 = 71.00%.

14
New cards

What is decision coverage's goal?

To cover all true/false outcomes of decisions.

15
New cards

What ensures path coverage?

Covering all paths from start to end.

16
New cards

What is source code debugging, and what tool is used?

A process in an IDE to investigate defects, using the IDLE debugger.

17
New cards

How does debugging differ from unit testing?

Debugging investigates defects, while unit testing verifies functionality.

18
New cards

What defect arises from mismatched programmer expectations?

A defect where the programmer's expectation doesn't match program execution.

19
New cards

Why is debugging challenging?

Lines execute quickly, and variable values change frequently.

20
New cards

How does a debugger help?

Steps through code line by line and shows variable values.

21
New cards

How can debugging be sped up?

Jump to specific code of interest instead of stepping through every line.

22
New cards

What does PyUnit advocate the idea of?

First testing then coding

23
New cards

What is Debugging?

Process of identifying and correcting logic errors.

24
New cards

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.

25
New cards

How do you access the IDLE Debugger?

Select "Debug" > "Debugger" in the Python Shell.

26
New cards

Name the five IDLE Debugger options.

Go, Step, Over, Out, Quit.

27
New cards

What does "Step" do in the debugger?

Steps one instruction, entering function calls.

28
New cards

What does “Go” do in the debugger?

Resume until breakpoint/end

29
New cards

What does “Over” do in the debugger?

Steps one instruction, doesn’t enter function calls but steps over them.

30
New cards

Debugger's power

Efficiently identifying and fixing defects.

31
New cards

Defects detected by compilers

Syntax errors, undeclared variables, unreachable code, etc.

32
New cards

What are modern compilers in defect detection

Data flow analysis and Control flow analysis.

33
New cards

Data flow analysis concern

How data is used on different code paths.

34
New cards

Three data variable states

Undefined (u), Defined (d), Referenced (r).

35
New cards

What can Data Flow Analysis do?

Identifies anomalies.

36
New cards

Ur-anomaly

Reading an undefined data item.

37
New cards

Du-anomaly

A defined item becomes undefined without use.

38
New cards

Dd-anomaly

Reassigning a defined item without using it.

39
New cards

What is the starting point of Path Testing?

Program flow graph that shows nodes representing program decisions and arcs representing the flow of control

40
New cards

Anomalies in FactorialExample

No explicit anomalies, but check n, counter, result usage.

41
New cards

Program flow graph description

Program control flow, with branches and loops.

42
New cards

Path testing objective

Ensure test cases execute desired paths at least once.

43
New cards

Flowgraph primitives

Decision, junction, process block.

44
New cards

Definition of a path

A sequence from entry/junction/decision to another, possibly repeating.

45
New cards

Complete path

A path from routine entry to exit.

46
New cards

Unit test tips

Provide meaningful or accurate messages in assert statements

47
New cards

Unit testing effect on debugging

Reduces debugging time if implemented correctly.

48
New cards

Purpose of unit tests

To verify code logic and detect regressions.

49
New cards

Other testing supported by unit frameworks

Integration and system-level testing.

50
New cards

What is PyUnit

A testing framework that enables us to quickly develop, execute and re-execute unit test cases for python code

51
New cards

What happens when Unit test fails for an individual programmer

Compilation fails until it passes.

52
New cards

What happens when a Unit test fails for a group of programmers

Group build fails, embarrassing the breaker.

53
New cards

Continuous Integration (CI)

Frequent code integration with automated builds.

54
New cards

CI benefit for error detection

Detects errors quickly and easily.

55
New cards

Characterization of a PyUnit test case

Known input and expected output.

56
New cards

Test cases per requirement

At least two: one positive, one negative.

57
New cards

What is a PyUnit Test case?

A piece of code that checks that another piece of code works as expected

58
New cards

Two PyUnit assertions

assertEqual(a, b) (a = b), assertNotEqual(a, b) (a != b).

59
New cards

What is Continuous Integration?

A development practice that requires developers to integrate code into a shared repository several times a day

60
New cards

What is the location debate for unit tests

Some advocate shipping unit test code to production systems, Some don’t.

61
New cards

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.

62
New cards

What does “Quit” do in debugging

Terminates the program.

63
New cards

What is a breakpoint in debugging?

A marker set by the programmer that temporarily halts program execution at a specified line of code.

64
New cards

What is a decision

program point at which the control can diverge (if and case statements)

65
New cards

What is a junction?

Program point where the control flow can merge. (end if, end loop)

66
New cards

What is a process block?

A sequence of program statements uninterrupted by either decisions or junctions

67
New cards

Unit Test Lifecycle

Write test code, Compile test code., Write/modify unit code, Compile code, Execute tests, Compare results, Iterate.

68
New cards

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.

69
New cards

Undefined

Variable has no value

70
New cards

Defined

Value has been assigned

71
New cards

Referenced

Value Used

72
New cards

What is a Control Flow Graph

visually maps all control paths through a program

73
New cards

What is a positive test?

Confirms expected output for valid input.

74
New cards

What is a Negative test?

Confirms correct handling of invalid input or errors.

75
New cards

What is a Test Suite?

Combine multiple test classes and Enable batch test execution

76
New cards

What do Continuous Integration systems do?

Running tests on commit and Flag regressions early

77
New cards

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.

78
New cards

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.

79
New cards

Test-Driven Development

test setup → test → code → unit test