Unit 3: Software testing
Software Engineering notes · PTU syllabus (BSIT503/BSBC401)
On this page
- Unit summary
- Testing objectives
- Testing principles
- Testability
- White-box test case design
- Black-box test case design
- Verification and validation
- Testing strategy: unit, integration, validation and system testing
- Unit and integration testing in detail
- Validation and system testing in detail
- Key terms
- Quick revision
- Important questions
Unit summary
Testing is the last line of defence before users meet defects. This unit covers testing objectives, principles and testability, white-box and black-box test case design, verification and validation, and unit, integration, validation and system testing.
After this unit you can
- State testing objectives and principles
- Design white-box test cases using basis path testing
- Design black-box test cases
- Explain verification, validation and the testing strategy
PTU syllabus topics
- Testing objectives
- principles and testability
- white-box and black-box test case design
- verification and validation
- unit/integration/validation/system testing
Topic 1
Testing objectives
- Testing is executing a program with the intent of finding errors; a good test case has a high probability of finding an undiscovered error; a successful test uncovers one (Glen Myers).
Example
A successful test: a test case enters a negative fee amount and the system accepts it — the test has found an error, so it is a successful test by Myers's definition.
Exam tip
Testing can show the presence of errors, never their absence.
Topic 2
Testing principles
- Traceable to requirements
- Tests check what customers need
- Planned early
- Test planning starts with requirements
- Pareto principle
- 80% of errors come from 20% of components
- Small to large
- Start with units, move to the system
- Exhaustive testing impossible
- Select test cases wisely
- Independent testers
- Third parties test more effectively
Example
The Pareto principle in testing: after testing a college ERP, 80% of the defects are found in the fee and exam modules (20% of modules), so testers concentrate extra effort there.
Exam tip
Learn Davis's principles: traceable to requirements, planned early, Pareto, small to large, exhaustive testing impossible, independent testers.
Topic 3
Testability
- Operability
- The better it works, the more efficiently it can be tested
- Observability
- What you see is what you test
- Controllability
- Inputs and states can be controlled
- Decomposability
- Modules can be tested independently
- Simplicity
- Less to test
- Stability
- Few changes during testing
- Understandability
- Good documentation
Example
Improving testability: a module that writes its results to a log and has a clear interface is easy to test (observability, controllability). A module with hidden internal state and no outputs is hard to test.
Exam tip
The characteristics: operability, observability, controllability, decomposability, simplicity, stability and understandability.
Topic 4
White-box test case design
- White-box (glass-box) testing uses the control structure of the code to guarantee that all independent paths, decisions, loops and internal data structures are exercised.
- 1Draw the flow graph from the code
- 2Compute cyclomatic complexity V(G)
- 3Find a basis set of independent paths
- 4Prepare a test case for each path
Edges and nodes
V(G) = E − N + 2
Predicate nodes
V(G) = P + 1
Regions
V(G) = number of regions of the flow graph
Example
A flow graph with 11 edges and 9 nodes: V(G) = 11 − 9 + 2 = 4, so four independent paths need four test cases.
- Other techniques: condition testing, data flow testing, loop testing (simple, nested, concatenated, unstructured loops).
Topic 5
Black-box test case design
Equivalence partitioning
Divide inputs into valid and invalid classes; test one value from each
Classes below 0, 0–100, above 100: test −5, 50, 120
Boundary value analysis
Errors cluster at edges; test at and around boundaries
−1, 0, 1, 99, 100, 101
Cause–effect graphing and decision tables
Map combinations of input conditions to actions
Fine rules for late returns
Graph-based testing
Model objects and relationships, test each link
Navigation between screens
- Black-box testing finds incorrect or missing functions, interface errors, data structure errors, performance and initialisation errors.
Example
Boundary value analysis: for marks valid from 0 to 100, test −1, 0, 1, 99, 100 and 101. Equivalence partitioning uses one value from each class — e.g. −5 (invalid), 50 (valid) and 150 (invalid).
Exam tip
Black-box tests are designed from requirements, without looking at the code.
Topic 6
Verification and validation
Question
Are we building the product right?
Are we building the right product?
Checks
Conformance to specifications
Meets user needs
Methods
Reviews, walkthroughs, inspections, static analysis
Testing the executable product with users
Timing
Throughout development
Mainly at the end of each stage and delivery
Example
V and V in a project: reviewing the design document against the requirements is verification. Letting the college staff use the finished system to confirm it meets their needs is validation.
Exam tip
Verification: 'Are we building the product right?' Validation: 'Are we building the right product?'
Topic 7
Testing strategy: unit, integration, validation and system testing
- 1Unit testing
Individual modules
- 2Integration testing
Modules combined: top-down or bottom-up
- 3Validation testing
Against requirements: alpha and beta
- 4System testing
Recovery, security, stress, performance
Based on
Specifications
Internal code
Techniques
Equivalence partitioning, boundary value analysis
Basis path testing, statement and branch coverage
Done by
Testers, users
Developers
Finds
Missing or wrong functions
Logic and path errors
Cyclomatic complexity V(G) = E − N + 2 (edges − nodes + 2) gives the number of independent paths to test. Debugging finds and fixes the cause of a failure, using brute force, backtracking or cause elimination.
Example
Strategy in practice: each module (login, fees, exams) is unit-tested; modules are then combined and tested together (integration); the full system is checked against requirements (validation); finally, it is tested with the real hardware, network and load (system testing).
Exam tip
Move from small (unit) to large (system).
Topic 8
Unit and integration testing in detail
Integration can be top-down (start from the main module, using stubs for lower modules) or bottom-up (start from lowest modules, using drivers to call them). Regression testing re-runs earlier tests after changes.
- Unit testing checks module interfaces, local data structures, boundary conditions, independent paths and error-handling paths, using drivers and stubs.
- Integration testing: top-down (depth-first or breadth-first, with stubs), bottom-up (clusters with drivers), regression testing after each addition, and smoke testing (daily builds).
Example
Stubs and drivers: testing the main menu before the report module is ready uses a stub that returns a fixed report. Testing the tax calculation before the main program exists uses a driver that calls it with test data.
Exam tip
Stub = dummy called module (top-down); driver = dummy calling module (bottom-up).
Topic 9
Validation and system testing in detail
Alpha testing is done by users at the developer's site; beta testing is done by users at their own sites. System testing includes recovery, security, stress and performance testing.
- Validation testing: checks the software against the SRS — validation test criteria, configuration review, alpha testing (at the developer's site) and beta testing (at customer sites).
- Recovery testing
- Force failures and verify recovery
- Security testing
- Attempt to break protection
- Stress testing
- Abnormal quantity, frequency or volume of load
- Performance testing
- Run-time performance within the integrated system
- Deployment testing
- Different platforms and installation procedures
Example
Stress testing: the college results portal is tested with 10,000 simultaneous users to check it does not crash on result day.
Exam tip
Name the types of system testing with one example each.
Key terms
- Testability
- Ease with which software can be tested
- Cyclomatic complexity
- Number of independent paths through code
- Equivalence partitioning
- Dividing input into classes tested by one value each
- Verification
- Checking that the product is built right
- Validation
- Checking that the right product is built
Quick revision
- Objectives and principles of testing; testability characteristics.
- White-box: basis path, V(G) three ways, loop testing.
- Black-box: equivalence partitioning, BVA, cause–effect, graph-based.
- Verification vs validation.
- Unit (drivers, stubs), integration (top-down, bottom-up, smoke), validation (alpha, beta), system tests.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.State the objective of testing.
- Q2.What is testability?
- Q3.Compute V(G) for a graph with 9 edges and 7 nodes.
- Q4.Distinguish equivalence partitioning and boundary value analysis.
- Q5.Distinguish verification and validation.
- Q6.What is smoke testing?
Long-answer questions
- Q1.Explain testing principles and testability.
- Q2.Explain basis path testing with an example.
- Q3.Explain black-box test case design techniques.
- Q4.Explain the testing strategy from unit to system testing.
Stuck on this unit?
Message SBS on WhatsApp for help with Software Engineering, or to ask about studying B.Sc IT at Synetic.
