Construction: programming management, documentation and testing
Managing the coding process, system and user documentation, test levels (unit, integration, system, acceptance), black-box and white-box testing, boundary values and writing test cases. The final brings test case table and test type questions.
Design is finished, and it is the turn of construction: code is written, tested and documented. This phase is usually the part of the project that needs the most people and time. Here the analyst manages and verifies rather than writing code: making sure the programmers work to the same plan, that the tests are tied to the requirements, and that the right document reaches the user. The final exam brings test levels, the difference between black-box and white-box, and the question “write the test cases for this function”.
Golden rules:
- Test levels in order: unit → integration → system → acceptance.
- Black-box from the specification, white-box from the code.
- Test at the boundary: lower − 1, lower, upper, upper + 1.
- Every alternate flow is a test case. The descriptions from week 7 are the raw material of the test plan.
Programming management
The project manager’s three jobs in this phase:
1. Assigning tasks to programmers. Modules (packages, classes) are distributed to programmers. Modules that depend heavily on each other are given to the same person or the same small team. As the team grows, the communication load grows (the channels of week 3), so “adding people to a late project” doesn’t work.
2. Coordinating activities.
- Weekly meetings, short progress reports.
- Standards: naming, coding, comment rules.
- Code control (source code control / version control): who changed which file, which version was tested. Tools like Git.
- Three environments: development, test, production. Code moves from one environment to the next in a controlled way.
3. Managing the schedule. The work plan is kept up to date and delays are noticed early. Scope creep is controlled in this phase too: new requests come in via a change request.
Classic mistakes:
| Mistake | Explanation |
|---|---|
| Research-oriented development | The team tries to learn a new technology it doesn’t know during the project; the schedule slips |
| Using low-cost personnel | A cheap but inexperienced team; the productivity difference is greater than the cost difference |
| Lack of code control | Version confusion, overwriting each other’s code |
| Inadequate testing | When the schedule gets tight, testing is the first thing cut; then the most expensive errors are found |
Documentation
| Type | For whom | Content |
|---|---|---|
| System documentation | Developers and the maintenance team | Analysis and design models, code comments, API documents, installation notes |
| User documentation | End users | How to use the system |
The three types of user documentation:
| Type | Question | Example |
|---|---|---|
| Reference documents (online help) | “What does this function do?” | “The Freeze button suspends the membership for up to 30 days.” |
| Procedures manuals | “How do I do this job?” | “How to renew a membership: 1. Profile 2. Membership 3. Renew …” |
| Tutorials | “How do I learn the system?” | A step-by-step guide on first use |
Pros of online documentation: it is searchable, easy to update, and tied to the screen (context-sensitive help). Documents are written in the user’s language: no technical jargon, task-oriented headings (“Make a class reservation”), short steps.
Testing
The test plan
The test plan starts in analysis. Each test case contains this information:
| Field | Example |
|---|---|
| Test ID | TC-04 |
| Purpose | The fine must not exceed the book price |
| Precondition | The book price is 100 TL |
| Input | daysLate = 80, isStaff = false |
| Expected output | 100.0 |
| Actual output | (written during testing) |
| Result | Pass / Fail |
Test levels
| Level | What is tested | How | Who |
|---|---|---|---|
| Unit | A single class / method | Black-box and white-box | Programmer |
| Integration | The modules working together | UI testing, use scenario testing, data flow testing, system interface testing | Test team |
| System | Whether the whole system meets the requirements | Requirements, usability, security, performance, documentation testing | Test team, analyst |
| Acceptance | Whether the user accepts it | Alpha (test data), beta (real data) | Users |
Types of integration testing: User interface testing (each interface function), use scenario testing (a use case end to end), data flow testing (does data flow correctly between modules), system interface testing (data exchange with external systems, e.g. the payment provider).
Integration strategies: Top-down (upper modules first, a stub in place of the lower ones), bottom-up (lower modules first, a driver in place of the upper caller), big bang (all at once; hard to find errors).
Types of system testing: requirements testing (is each requirement met), usability testing, security testing, performance testing (load, stress: the 167 requests/s target of week 12), documentation testing (do the steps in the documents really work).
Black-box and white-box
| Black-box | White-box | |
|---|---|---|
| Source | Specification (requirements, description, class contract) | Source code |
| What is examined | Input → expected output | Branches, loops, paths |
| Techniques | Equivalence partitioning, boundary value analysis | Statement/branch coverage, cyclomatic complexity |
| What it catches | Missing or wrong function | Code that never runs, a wrong branch |
Equivalence partitioning: Divide the input space into classes expected to behave the same way, and test one value from each class. Boundary value analysis: test below each boundary, the boundary itself, and above it.
Cyclomatic complexity: The number of independent paths in the code.
is the number of edges and the number of nodes in the flow graph. At least test cases are needed for branch coverage.
Worked example: a fine calculation method
A method from the library system. The rule: 2 TL for each day late; staff pay half price; the fine cannot exceed the price of the book; if there is no delay the fine is 0.
static double fine(int daysLate, boolean isStaff, double bookPrice) {
if (daysLate <= 0) return 0;
double f = daysLate * 2.0;
if (isStaff) f = f / 2;
if (f > bookPrice) f = bookPrice;
return f;
}
Step 1: Cyclomatic complexity. Three ifs → V(G) = 3 + 1 = 4. At least four independent paths:
Path 1: daysLate <= 0 → return 0
Path 2: >0, not staff, below the cap
Path 3: >0, staff, below the cap
Path 4: >0, not staff, above the cap
Step 2: Black-box classes and boundaries. For daysLate: ≤ 0 (no fine), ≥ 1 (there is a fine). Boundary: 0 and 1. For the fine: below the price, equal to it, above it.
Step 3: The test case table (bookPrice = 100):
| ID | daysLate | isStaff | Expected | What it tests |
|---|---|---|---|---|
| TC1 | 0 | false | 0.0 | Boundary: no delay |
| TC2 | 5 | false | 10.0 | Normal fine (path 2) |
| TC3 | 5 | true | 5.0 | Staff discount (path 3) |
| TC4 | 80 | false | 100.0 | Upper bound: the book price (path 4) |
| TC5 | 1 | false | 2.0 | Boundary: the first day of fine |
| TC6 | -3 | false | 0.0 | Invalid/negative input |
When you run them all:
System.out.println("TC1 " + fine(0, false, 100));
System.out.println("TC2 " + fine(5, false, 100));
System.out.println("TC3 " + fine(5, true, 100));
System.out.println("TC4 " + fine(80, false, 100));
System.out.println("TC5 " + fine(1, false, 100));
System.out.println("TC6 " + fine(-3, false, 100));
TC1 0.0
TC2 10.0
TC3 5.0
TC4 100.0
TC5 2.0
TC6 0.0
PITFALL · testing only the “happy path”. TC2 passes on its own and makes the method look “correct”. Most errors show up at the boundaries (TC1, TC5), at the limits (TC4) and with unexpected input (TC6).
TIP · test cases from use cases. Every alternate flow in the Reserve Book description from week 7 (2a, 3a, S-1.2a, S-1.3a, 5a) is a system test case. The normal flow is one too: at least 6 test cases are ready.
Common mistakes
| Wrong idea | The truth |
|---|---|
| Testing starts in implementation | The test plan starts in analysis |
| Black-box examines the code | It uses the specification; white-box examines the code |
| Boundary value = only the boundary itself | Below it, itself, above it |
| Stub = driver | A stub stands in for the called module, a driver for the caller |
| Programmers do the acceptance test | Users do |
| Alpha with real data, beta with test data | The reverse: alpha is test data, beta is real data |
| Procedures manual = reference doc | A reference document describes a function, a procedures manual describes a task |
| V(G) = number of ifs | V(G) = number of decisions + 1 |
Test yourself
Exam-style questions. Solve them on paper first, then reveal the answer.
Which test level checks that individual classes or methods work correctly in isolation?
- Unit test
- Integration test
- System test
- Acceptance test
Show answer
A unit test tests a single module (class, method) on its own. An integration test tests the modules working together, a system test tests whether the whole system meets the requirements, and an acceptance test tests whether the user accepts the system.
Black-box testing designs test cases from what?
- The source code structure
- The specification (requirements, use case descriptions, class contracts)
- Programmer intuition only
- The database schema
Show answer
In black-box testing you do not look inside the code; the inputs and expected outputs are derived from the specification. In white-box testing, test cases are written by examining the structure of the code (branches, loops, paths).
A reservation length must be between 1 and 48 hours (integers). Using boundary value analysis, which values should you test?
Show answer
Errors concentrate at the boundaries. For each boundary, the value just below, the boundary itself and the value just above are tested: for the lower boundary 0 and 1 (and 2), for the upper boundary 48 and 49 (and 47). 0 and 49 should be rejected, 1 and 48 should be accepted.
Using equivalence partitioning for the same rule, how many partitions are there?
Show answer
Inputs expected to behave the same way are gathered in one class, and one representative from each class is tested: −5 (invalid), 24 (valid), 60 (invalid). A non-numeric input can also be added as a fourth invalid class.
What does the method on this page return for fine(30, true, 25)?
static double fine(int daysLate, boolean isStaff, double bookPrice) {
if (daysLate <= 0) return 0;
double f = daysLate * 2.0;
if (isStaff) f = f / 2;
if (f > bookPrice) f = bookPrice;
return f;
}Show answer
daysLate = 30 > 0. f = 30 × 2.0 = 60.0. isStaff is true → f = 30.0. 30.0 > 25 → f = 25.0. The fine is capped at the price of the book.
Same method: what does fine(50, false, 100) return, and why is it a good test case?
Show answer
f = 50 × 2.0 = 100.0. 100.0 > 100 is false, so f does not change: 100.0. If >= were mistakenly written at the boundary (equality) instead of >, the result would be the same, but you would see the difference with 51 days; the equality and one more are tested together.
What is the cyclomatic complexity of the fine() method?
Show answer
There are three decision points (three ifs). V(G) = number of decisions + 1 = 4. From the flow graph too: in a graph with a single exit, 12 edges and 10 nodes → 12 − 10 + 2 = 4. In white-box testing at least 4 independent paths should be tested.
A method has 4 if statements and 1 while loop (no compound conditions). What is its cyclomatic complexity?
Show answer
Each if and each loop is a decision point: 4 + 1 = 5 decisions. V(G) = 5 + 1 = 6.
During integration testing, module A calls module B, which is not written yet. What do you use in place of B?
- A driver
- A stub
- A beta tester
- A regression test
Show answer
A stub is a simple fake module that stands in for a module that has not yet been written and is called (top-down integration). A driver, in contrast, is test code that stands in for a module that has not yet been written and does the calling (bottom-up integration).
Acceptance testing done by users at the developer's site with test data is called what? And when done at the user's site with real data?
Show answer
Alpha test: users try the system in a controlled environment with test data. Beta test: users use the system in the real environment with real data and report problems. Both are part of acceptance testing.
Which document type helps a user complete a specific business task step by step, such as 'How to renew a membership'?
- Reference document
- Procedures manual
- Tutorial
- System documentation
Show answer
A reference document: explains what a function does (online help). A procedures manual: explains how to do a business task from start to finish. A tutorial: teaches the system. System documentation is for developers and maintainers.
Why is regression testing needed after fixing a bug?
Show answer
A change may break other places. Regression testing is re-running the tests that passed before. An automated test suite (unit tests) is valuable for this reason.
Verification: The expected outputs of all test cases of the fine() method were run with the JDK (java verify/SEN2022/Fine13.java). Cyclomatic complexity was computed in node both as V(G) = E - N + 2 and as number of decisions + 1; the boundary value and equivalence class lists are in the same file (verify/SEN2022/13.mjs). Conceptual questions were compared with the standard test level and documentation definitions.