Course outline: Test design
Module 02 · Test design
Levels of software testing
From one function to the whole product in the hands of its users: the four levels, who owns each, and what each one finds.
What you'll be able to do
- Name the four levels of testing, who usually performs each, and what each one is placed to find.
- Choose an integration approach (big bang, bottom-up, top-down or sandwich) and say what stubs and drivers are for.
- Tell system testing from integration testing, and alpha and beta tests from the other kinds of acceptance.
- Plan one feature across all four levels, so that no level is asked to do another level's job.
The Hierarchy of Software Verification
Software testing isn't a single activity but a structured process involving multiple levels of verification. Each level focuses on a specific scope, building confidence progressively from the smallest code units to the complete system in its operational environment.
Understanding these levels—Unit, Integration, System, and Acceptance Testing—is crucial for QA professionals to design effective test strategies, detect defects early, ensure comprehensive coverage, and ultimately deliver high-quality software that meets user expectations.
The Testing Pyramid
Tests build upon each other, starting from the smallest units.
1. Unit Testing
Definition: Unit testing is a type of software testing where individual, isolated units or components of software (like functions, methods, or modules) are tested to validate their correctness.
Performed By: Developers during the coding phase.
Why Perform Unit Testing? Inappropriate unit testing leads to high costs for defect fixing later. Proper unit testing saves time and money in the long run.
Key Reasons:
- Fix bugs early in the development cycle and save costs.
- Helps developers understand the codebase and make changes quickly.
- Good unit tests serve as project documentation.
- Helps with code re-use; migrate code and tests together.
Types:
Manual, Automated
Tools:
Jtest, Junit, NUnit, EMMA, PHPUnit, TestNG
Advantages:
- Allows developers to understand unit functionality and API.
- Refines code and ensures module correctness.
- Enables testing parts of the project without waiting for others.
Disadvantages:
- Writing test cases can be time-consuming.
- Will not cover all errors, especially integration issues.
- Not efficient for UI testing.
- Requires maintenance when source code changes frequently.
- Cannot cover non-functional testing (scalability, performance).
Example:
Main function:
int Add(int a, int b) { return a+b; }Unit test code:
void TestAdd1() { Assert.IsEqual(Add(5, 10), 15); }2. Integration Testing
Definition: Integration testing is where software modules are integrated logically and tested as a group to expose defects in their interactions.
Performed By: Developers, QA, or specialized integration teams.
Advantages:
- Ensures integrated modules work properly together.
- Testing can start once relevant modules are available.
- Detects errors related to interfaces between modules.
- Helps verify interactions with APIs and third-party tools.
- Typically covers a large volume of the system, increasing efficiency.
- Increases test coverage and reliability.
Example:
Check that after adding items to the cart, the checkout module correctly receives that information and calculates shipping costs.
Approaches:
- Big Bang Approach:
- All components are integrated at once and tested as a single unit. Requires all components to be ready.
Example: Waiting for the Login, User Profile, and Order History modules to be complete before testing them together. - Bottom-Up Approach:
- Lower-level modules are tested first, then used to facilitate testing of higher-level modules, progressing upwards.
Example: Testing the database connection module first, then the data retrieval module that uses it, and finally the UI display module that shows the data. - Top-Down Approach:
- Higher-level modules are tested first, often using 'stubs' (dummy modules) for lower-level dependencies. Testing progresses downwards.
Example: Testing the main application UI first, using stubs for the payment processing and inventory modules, then replacing the stubs as the actual modules become available. - Sandwich Testing (Hybrid):
- Combines Top-Down and Bottom-Up. Top-level modules are tested with lower-level modules, while lower modules are integrated with top modules simultaneously. Uses both stubs and drivers.
Example: Testing the UI layer (top) with stubs for business logic, while simultaneously testing the data access layer (bottom) with drivers, and then integrating the middle business logic layer.
3. System Testing
Definition: System testing validates the complete and fully integrated software product against its specified requirements. It evaluates the end-to-end system behavior.
Performed By: Independent QA/Testers.
Advantages:
- Testers don't need deep programming knowledge (Black Box).
- Tests the entire product, finding errors missed in earlier stages.
- Uses a testing environment similar to production.
- Checks overall functionality against business and technical requirements.
- Increases confidence before moving to acceptance testing.
Disadvantages:
- More time-consuming than unit or integration testing.
- Can be expensive as it tests the entire system.
- Requires good debugging tools to find hidden errors.
Example:
Simulate a full customer journey—searching for products, adding them to the cart, checking out, and receiving an order confirmation email—to ensure the entire system works seamlessly.
4. Acceptance Testing
Definition: Acceptance testing is performed by end-users or clients to verify/accept the software system against their business requirements before it moves to production.
Performed By: Clients, End-users.
Common Types:
- (Verifies the software meets user needs in real-world scenarios.):
- Assesses if the product works correctly for user usage, focusing on frequently used requirements. Also called End-User Testing.
- Alpha Testing:
- Performed by internal teams (e.g., QA, product owners) in a controlled environment near the end of development. Feedback helps improve the product.
- Beta Testing:
- Performed by a limited set of actual end-users (beta testers) in their real environment before official release. Feedback is collected to fix issues and enhance user experience.
Other Types:
(Ensures the software meets business objectives and processes.), (Verifies the software meets criteria specified in a contract.), (Ensures compliance with legal and regulatory standards.), (Checks the system's readiness for operation and maintenance.).
Example:
Have a selected group of customers or stakeholders use the e-commerce site’s new feature (e.g., “Buy Now” button) in a staging environment and give feedback on usability and correctness before it goes live.
System Testing vs. Integration Testing
| Aspect | System Testing | Integration Testing |
|---|---|---|
| Goal | Testing the completed product against specification requirements. | Testing the collection and interface of modules for expected results. |
| Scope | Both functional and non-functional testing (usability, performance, etc.). | Primarily functional testing of combined module outcomes. |
| Level | High-level testing performed after Integration Testing. | Low-level testing performed after Unit Testing. |
| Approach | Black Box testing (no internal code knowledge required). | Can be Black Box, White Box, or Gray Box (may require code knowledge). |
| Performed By | Test Engineers only. | Developers and/or Test Engineers. |
| Defect Scope | Defects found relate to the system as a whole. | Defects found relate to interfaces between individual modules. |
| Test Cases | Developed to simulate real-life scenarios. | Developed to simulate interactions between modules. |
| Testing Types Covered | Sanity, usability, maintenance, regression, performance, etc. | Big Bang, Top-Down, Bottom-Up, Sandwich approaches. |
Testing Levels Summary
| Testing Level | Performed By | Focus | Typical Phase in SDLC | Example |
|---|---|---|---|---|
| Unit Testing | Developers | Individual code modules | During Development | Test a single function |
| Integration Testing | Dev/QA/Integration team | Interaction between modules | After Unit Tests | Test how cart works with checkout |
| System Testing | QA/Testers | Entire system behavior | After Integration Tests | Test full end-to-end workflows |
| Acceptance Testing | End Users/Clients | Meeting user/business needs | After System Testing | Users validate final application |
Worked example · Cedar Books
The coupon feature at four levels
Cedar Books, the Academy's practice shop, lets a shopper type one coupon code in the basket (REQ-03): CEDAR10 takes 10% off. Here is the same feature tested at each of the four levels. Each level looks at a different thing, so each is placed to catch a different kind of bug.
| Level | Who | What is tested | The kind of bug it is placed to catch |
|---|---|---|---|
| Unit | The developer, while coding | The discount function alone: CEDAR10 on 19.00 takes 1.90; on an empty basket it takes nothing | A wrong sum, or a rounding that gains or loses a cent |
| Integration | A developer or a tester | The coupon API with the basket: after a code is applied, the basket shows one discount line and a new total; a second code replaces the first | Two parts that disagree, such as a basket total that ignores the discount |
| System | An independent tester | The whole journey in a browser on the test environment: find a book, add it, apply CEDAR10, pay with the approved test card, read the confirmation in the mailbox | A journey that breaks between pages, such as a discount shown in the basket but not charged |
| Acceptance | The shop owner and a few real customers | The feature on staging, used the way customers will use it, including the codes printed on this month's flyer | Software that works as written but not as the business needs, such as a coupon field too easy to miss on a phone |
The unit test is a few lines and runs in milliseconds:
test('CEDAR10 takes 10% off', () => {
expect(discountCents('CEDAR10', 1900)).toBe(190);
expect(discountCents('CEDAR10', 0)).toBe(0);
});It counts money in whole cents (1900 is 19.00), which keeps the computer's way of storing decimals from adding a stray fraction of a cent.
No level replaces another. The unit test pins the sum but cannot see the basket. The integration test sees the parts working together but not the screens. The system test sees the whole journey but is slow, and when it fails it says less about where the fault is. Acceptance answers a question none of the others asks: is this what the business wanted?
Try it: cURL to API tests · The journey lab
Key Takeaways
- Layered Approach: Testing levels provide a structured hierarchy (Unit → Integration → System → Acceptance) for thorough software validation.
- Early Defect Detection: Each level aims to catch defects specific to its scope, preventing them from propagating to later stages where they are costlier to fix.
- Scope Variation: Testing focus shifts from individual code components (Unit) to interactions (Integration), the entire system (System), and finally user/business requirements (Acceptance).
- Collaboration: Different roles (Developers, QA, End Users) are typically involved at different levels.
- Confidence Building: Successfully passing each level increases confidence in the software's quality and readiness for release.
Sign in to keep your progress: a tick here lives in this browser only.
Test yourself
Quiz: Levels of testing
10 questions, about 8 minutes. Sign in to take the quiz.
10 questions, about 8 minutes, no time limit. 7 right answers pass, and passing marks the lesson as read. Every new quiz draws new questions.