Programming · Testing
up to +100 XP
Stop 2.12 · Programming · 3 min

Testing

Ensure your code works correctly and reliably

Learning objectives:
  • Understand why components are tested separately (2.12.1.1)
  • Know and use the testing methods (2.12.2.1–2.12.2.2)
  • Know automation methods (2.12.3.1)
  • Know test data types, create test data and know the structure of a test plan (2.12.4.1–2.12.4.3)

Testing components first

Test each component on its own before joining them into the final solution: the software, hardware, data, interfaces and the resulting service (final product). Faults are easier to find and cheaper to fix in one small part than in the whole system, and you can trust each part when you combine them.

Testing methods

MethodWhat it testsWhen
ConceptWhether an idea or design meets users' needs, before it is builtVery early
UnitOne function, procedure or module on its ownDuring development
BoundaryValues at the edges of what is allowedWhen validation is added
IntegrationThat separate parts work togetherWhen parts are joined
PerformanceSpeed and responsivenessBefore release
SystemThe complete system against its requirementsWhen it is finished
AcceptanceThat the client agrees it meets their needsBefore sign-off
UsabilityHow easy it is for real usersWith users, before release
RegressionThat changes have not broken parts that workedAfter every change
Load/stressBehaviour under heavy and extreme useBefore go-live
Closed boxInputs and outputs only, without looking at the codeAny stage, often by testers or users
Open boxThe internal logic and paths through the codeDuring development, by developers

Each has a trade-off. For example, open box testing is thorough but needs coding knowledge; closed box testing reflects how users see the system but can miss untested paths in the code.

Automation

Automation makes testing faster, more consistent and repeatable (ideal for regression testing), but takes time to set up and cannot judge things like how easy something is to use.

Test data

For a field that accepts ages 16 to 19:

TypeMeaningExample
ValidData that should be accepted17
InvalidData of the right type that should be rejected25
BoundaryValues at the edge of the allowed range16, 19 (and 15, 20 just outside)
ErroneousData of the wrong type that should be rejected"seventeen"

Test plans

A test plan sets out testing before it happens so nothing is missed. It:

  1. identifies the tests to be carried out
  2. describes the purpose of each test
  3. identifies the test data to be used
  4. describes the expected results
  5. records the actual results.
TestPurposeTest dataExpected resultActual result
1Accept a valid age17Accepted
2Reject age above range20"Age must be 16 to 19"
3Reject text"abc""Enter a whole number"
Quick check · 14 questions · up to 100 XP

Check what stuck.

+10 XP each
Question 1

Question 1 of 14

Why test components separately before putting them together?

Question 2

Question 2 of 14

Which testing method checks that separate parts work together?

Question 3

Question 3 of 14

Which testing method checks that changes have not broken parts that already worked?

Question 4

Question 4 of 14

Which testing method checks behaviour under heavy and extreme use?

Question 5

Question 5 of 14

Which testing method looks only at inputs and outputs, without looking at the code?

Question 6

Question 6 of 14

Which testing method checks that the client agrees the system meets their needs?

Question 7

Question 7 of 14

Which automation method replays a recorded sequence of actions?

Question 8

Question 8 of 14

A field accepts 16 to 19. Which is boundary test data?

Question 9

Question 9 of 14

A field accepts 16 to 19. Which is erroneous test data?

Question 10

Question 10 of 14

Which is NOT one of the steps of a test plan in the specification?

Question 11

Question 11 of 14

What is a drawback of automated testing?

Question 12

Question 12 of 14 · Match the pairs

Match each type of test data to an example for "age 16 to 19".

Valid
Invalid
Boundary
Erroneous
Question 13

Question 13 of 14 · Match the pairs

Match each testing method to what it checks.

Unit
System
Usability
Open box
Question 14

Question 14 of 14 · Fill in the blanks

A test plan records the test, its purpose, the test data, the result and the result.