GCSE · Computer Science · OCR · Spec J277

Purpose of testing

Every part of your app passed its tests. You join them up, press go… and something breaks. How? That's why testing never happens just once.

Computer Science · Testing

Priya builds a cinema booking program

Pick a moment from Priya's build, then pick the kind of testing it shows.

Still to sort

Iterative testing (0)

One section of code, tested as soon as it's written.

Where the line is: Only one newly written section is being checked, and its errors get sorted before the next section is started.

Integration testing (0)

Modules that passed on their own, now tested together.

Where the line is: The modules have already been tested separately. Joining two of them mid-build isn't the same as testing the finished program.

Final testing (0)

The finished program, tested as a whole. The last phase.

Where the line is: This waits until the program is considered completely finished. If parts are still being written, it isn't final testing yet.

6 of 6 still to sort.

Priya writes her program in three modules: ticket price, seat picker and payment. Follow her through the build. At each moment, decide what kind of testing she's doing. Commit first, then read why.

Watch out: Don't sort by how big the test sounds. Ask what has just been built: one new section, already-tested modules being joined, or the finished program.

Think it through

Every module passed. Now what?

Sam is halfway through building a quiz app. He's written three modules: questions, scoring and a leaderboard. Each one has passed its own tests.

Which idea is closest to what you think Sam should do about testing now?
How sure are you?

White box vs black box

White box testingvsBlack box testing

Same program, two ways to test it. The question that settles it: do you look at the code?

Focus

Look at the code?

White box testing

Yes. The person designing the tests looks at the code in detail.

Black box testing

No. How the system has been coded isn't checked.

The insight

Lead with this difference. Everything else follows from it.

What the test designer has to understand

White box testing

How the code works.

Black box testing

What the system is supposed to do.

Testing Priya's ticket prices

White box testing

Read the code that sets the price and work out how it decides.

Black box testing

Type in ages and check the right price comes out.

Computer Science · Testing

Test table: Priya's ticket prices

The rule Priya's program should follow: under-16s pay £5, everyone else pays £8. Each step adds one test to the table.

Step through the tests. Keep your eyes on Expected and Actual: the moment they disagree, something's wrong.

TestDescriptionInputExpectedActualHow fixed
1Child ticket10£5£5

Output

 

Step 1: Expected £5, got £5. Test 1 passes, so there's nothing to fill in under How fixed.

1 / 4

Each row is one test. Expected is decided before the test runs; Actual is only known once it has run.

Step 1 of 4: Expected £5, got £5. Test 1 passes, so there's nothing to fill in under How fixed..

Your turn

Write it, then mark it

A programmer has nearly finished a program for a school library. Explain why the program should be tested. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Testing isn't one big check at the end. Code gets tested as it's written, again when the parts are joined, and finally as a whole.

What you need to know

  • Testing checks a program works correctly, meets its requirements and is free from bugs or errors.
  • It catches errors before users meet them, checks different inputs work as expected, and improves reliability and user experience.
  • Testing happens throughout development. The overall approach is agreed and planned to suit what the system is required to do.
  • Iterative testing (also called module or unit testing): write a section, test it, fix its errors, then start the next one.
  • Have a goYou've just written the 'add to basket' section of a shop program, and you're itching to start the checkout section. Using iterative testing, what has to happen first?

    Test the basket section and fix its errors.

    Iterative testing resolves each section's errors before the next section is developed; saving them all up for later is exactly what it avoids.

  • Integration testing takes modules already tested separately and tests them together, to check they're compatible and work as expected.
  • Why bother? A module that works on its own may cause errors once it's part of the wider system.
  • Have a goYour mate's two modules both passed their own tests. "Joined them up. No need to test again, they're both perfect," he says, already reaching for the crisps. Is he right?

    No. They still need testing together.

    Passing alone doesn't prove they'll work together: a module that works on its own may still cause errors once it's part of the wider system.

  • Final testing is the last phase, once the program's considered finished: every pathway, a full range of input data.
  • White box: the test designer looks in detail at the code and how it works. Black box: checks what it does, not how it's coded.
  • Have a goA tester reads through the if statement that sets ticket prices, works out how it decides each price, then designs tests from that. White box or black box?

    White box.

    She's looking in detail at the code and how it works. Black box would check the prices that come out without looking at how it's coded.

  • A test table's headings include test number, description, input, expected output, actual output, and how a failed test was fixed.
  • A failed test may mean a bug. Debugging finds and corrects it, so the program works correctly and meets its functional requirements.

The big picture

Testing checks that a program works correctly, meets its requirements and is free from bugs or errors, so problems are found and fixed before users meet them. It happens throughout development: iterative testing checks each new section as it's written, integration testing checks that modules already tested on their own work together, and final testing checks the finished program as a whole. White box testing looks in detail at the code; black box testing checks what the system does without looking at how it's coded. Results go in a test table, and a failed test may mean a bug that needs debugging.

Key points

1Testing is about a program working correctly, meeting its requirements and being free from bugs, with errors fixed before users experience problems.
2Three moments in development: iterative testing as each section is written, integration testing when tested modules are joined, final testing on the finished program.
3Integration testing exists because modules that work separately can cause errors together.
4White box testing looks at the code; black box testing checks functionality without looking at how it's coded.
5A test table compares expected output with actual output; a mismatch may mean a bug, which debugging finds and corrects.

Worked example

Problem

A student wrote: "Integration testing is when you test the whole program at the end to check it all works." Improve this answer.

⚠ Watch out

Mixing up white box and black box. Black box testing doesn't look at how the code works; it checks the system does what it's supposed to. White box is the one where the test designer looks in detail at the code.

🧠

Memory hook

Build a bit, test a bit (iterative). Join the bits, test the joins (integration). Finish it, test the lot (final).

✓

Check yourself

Without looking back: name the three kinds of testing in the order they happen during development, and say in one line what makes white box testing different from black box testing.

Flashcards

(14)
What is software testing?
Checking whether a program works correctly, meets its requirements and is free from bugs or errors.
How does testing help the people who will use a program?
Errors are found and fixed before users experience problems, and the program becomes more reliable and better to use.
Why test a program with more than one input?
To make sure it works as expected with different inputs, not just the one you happened to try.
When is testing carried out?
Throughout the development process, with an overall approach agreed and planned depending on the requirements of the system.
Iterative testing is also known as…
Module testing or unit testing.
What happens in iterative testing?
The programmer writes an individual section of code, tests it to make sure it functions correctly, and resolves any errors before the next section is developed and tested.
What is integration testing?
Testing modules that have already been tested separately together, to make sure they're compatible and function as expected.
Why can't you skip integration testing when every module has passed?
A module that works on its own may cause errors when it's incorporated into a wider system.
When does final testing happen?
Only when the whole program is thought to be complete, with nothing left to write. No testing phase comes after it.
What does final testing check?
Each pathway through the program, to make sure the system works as a whole, meets the project's requirements and works correctly with a full range of input data.
White box testing
The person designing the tests looks in detail at the code and understands how it works.
Black box testing
Focuses on functionality: checks the system does what it's supposed to do, without checking how it's been coded.
Headings in a test table
Test number, test description, input, expected output, actual output and, if the test was unsuccessful, how it was fixed.
What is debugging, and why does it matter?
Finding and correcting bugs in code. It makes the program work correctly and meet its functional requirements, and improves the user experience.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More OCR GCSE Computer Science topics

See the full OCR Computer Science curriculum →

How this lesson was checked. This OCR GCSE Computer Science (specification J277)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 3 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.