Testing Your Code

KS3 Computer Science

11-14 Years Old

48 modules covering EVERY Computer Science topic needed for KS3 level.

GCSE Computer Science

14-16 Years Old

45 modules covering EVERY Computer Science topic needed for GCSE level.

A-Level Computer Science

16-18 Years Old

66 modules covering EVERY Computer Science topic needed for A-Level.

KS3 Testing and Validation (14-16 years)

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

A-Level Software Development Lifecycle (16-18 years)

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

Candidates should be able to:

  • describe syntax errors and logic errors which may occur while developing a program
  • understand and identify syntax and logic errors
  • select and justify test data for a program, stating the expected outcome of each test.

What are syntax errors?

Syntax errors are errors that occur when instructions do not follow the rules or the grammar of the programming language. The instruction cannot therefore be executed and an error message will usually be generated. Examples of syntax errors include:

  • Spelling errors with keywords
    i.e.

     

    PENCOLOUR = "#00FF00"

    instead of

    PENCOLOR = "#00FF00"
  • Spelling errors with variables
    i.e.

     

    max_value = 100, 
    PRINT maxvalue
  • Missing or extra brackets or separators in an instruction.
    i.e.

     

    IF(answer="True",,"Correct","Wrong"))
  • Missing arguments in an instruction.
    i.e.

     

    DRAWRECTANGLE(50,50)

    should be

    DRAWRECTANGLE(50,50,200,400)
  • Not closing iteration loops correctly.
    i.e. missing the ENDWHILE from a WHILE / ENDWHILE loop.
  • Not putting double quotes around text so the program assumes the text is a variable.
    i.e.

     

    PRINT Hello World

What are logic errors?

Logic errors do not stop a program running or produce error messages but will result in a program not running in the way it was expected to. Examples of logic errors include:

  • Errors in a mathematical formula.
    i.e.

     

    result = (total + step) * 12

    will sometimes produce a different result to

    result = total + (step * 12)

    or

    result = total + step * 12
  • Sequential instructions in the wrong order.
    i.e.

     

    count = count + 1
    PRINT count

    VS

    PRINT count
    count = count + 1
  • The wrong conditions being set in iteration loops so the loop does not repeat the expected number of times.
  • The wrong conditions being set in conditional instructions.
    i.e.

     

    IF A > 100

    rather than

    IF A >= 100

    or using ELSE instead of ELSEIF.

  • Referring to variables that have not been set correctly.
    i.e.

     

    count = count + step

    when step has not previously been assigned a value.

  • Type mismatch errors.
    i.e. trying to add number variables but having the program treat them as text:

     

    num1 = 9, num2 = 9, PRINT num1 + num2

    gives 99 rather than 18.


What is test data?

Testing is carried out once syntax and logic errors have been corrected and a program appears to be running correctly. Testing should cover as many type of input/processing/output data and program operation as possible. It is important to try and ‘break’ the program, not simply to to show that it works is the right values are input.
Typical test input data can include:

  • Normal data – data that should be accepted
  • Borderline/extreme data – data that tests the limit of what should be accepted, i.e. just above, just below and actually on the limit
  • Erroneous data – data that should be rejected

A test plan is made up of the test data, the justification for the test and the expected test outcome. A test plan is often in the form of a table such as the example below:

Test dataValidation rule being testedTest typeExpected resultActual result
MrsTitle field member list check
(Mr, Mrs, Miss, Ms, Dr)
NormalData accepted 
MzTitle field member list check
(Mr, Mrs, Miss, Ms, Dr)
ErroneousData rejected with a suitable error message 
10Title field member list check
(Mr, Mrs, Miss, Ms, Dr)
ErroneousData rejected with error message 
10Staff discount range check
(between 1 and 20)
NormalData accepted 
-2Staff discount range check
(between 1 and 20)
ErroneousData rejected with a suitable error message 
20Staff discount range check
(between 1 and 20)
BorderlineData accepted 
20.01Staff discount range check
(between 0 and 20)
BorderlineData rejected with a suitable error message 
19.99Staff discount range check
(between 1 and 20)
BorderlineData accepted 
TenStaff discount data type check (between 1 and 20)ErroneousData rejected with a suitable error message