





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






The simplest kind of error: when a command is not a legal command or statement in the programming language.
However, because of the way programming languages are parsed, errors are not always reported at the point they occur.
When searching for syntax errors, check where the computer tells you the problem is; but if you don't find the error there, track back through the previous lines.
We also need to test for: Run Time errors - where the error can only be detected when the program runs. Specification errors - where the program does not crash or halt but does not do the right thing.
Only basic programs with no input (which are really only written when learning) can be tested just by running them once.
If a program has input, even for a very simple program, it would be impossible to test all possible input values.
Run-time and specification errors may only appear when certain values are en- tered, and not all the time.
Usual run testing techniques can be divided into two categories:
Black Box Testing
White Box (or Clear Box) Testing
Black-box testing treats a program as a 'black box' without considering the actual code.
It focuses on checking if the program's behaviour aligns with algorithm outcomes or requirements specifications. Test cases are developed to cover various scenarios, and specific test data is produced and used for the testing process.
create test cases, create test data, carry out testing and obtain test results
These are human statements of particular circumstances in which the program/al- gorithm will need to run
Must check that all necessary cases are covered
These are particular inputs or situations to run the program in to reproduce the test cases
Must check that they do indeed reproduce the test cases - none are skipped or accidentally made simpler
Run the program test data and note the results
Analyse the results and check they are what is expected; if not, attempt to identify the error
This process can be performed on the algorithm before implementation by work- ing it through by hand - although this is slower it avoids wasting time implementing a doomed algorithm
We need to be sure that we are testing every type of situation the software will face.
It is called white box or clear box as the tester inspects the actual code, unlike in black box testing.
As the tester knows the actual code, the testing can be tailored to ensuring that the lines of code are correct; unlike black box testing which only worries about matching the specification.
Security holes
Broken or poorly structured paths in the code
Correct flow of inputs through the code
Expected output
Correct functionality in conditional loops
Correctness of each statement
§Understand the source code. -Unlike black box testing, knowledge of the code is required to carry out white box testing ettectively.
§Create test cases and execute. -By looking at the code, the tester can determine what needs to be tested and provide tests for it. -Each part of the code will be looked at and used to inform test cases. -Code coverage determines how well the code has been covered by the testing.
§Statement coverage -Have the set of tests together caused every part of the program/algorithm to run or take ettect?
§Decision coverage
-Have the set of tests together caused every decision the program/algorithm makes to be decided in every possibly way?
§Condition Coverage -Similar to decision coverage but refers to decisions that are stored as well as immediately acted on.
§Parameter Value coverage -If a sub-program takes inputs, have all common values for such inputs been considered?
In clear box testing we choose only one value for each set of conditions because clear box testing? further variation should make no ditterence to the program.
§You should usually use both black box and clear box testing on each program.
Black box testing alone can fail to test all parts of the code.
White box testing alone can fail to allow for all aspects of the specification, become "lost" in the code's structure, or miss faults caused by errors in the algorithm rather than the implementation.
-Unit Testing. -Integration Testing. -System Testing. -Regression Testing.
Unit testing involves testing individual units of a program separately.
While larger programs can be divided into parts, the focus is on testing small components.
defining an algo- rithm?
In an implementation or requirements specification we may have to decide what the program should do if an invalid value is input.
§Of the right type but outside of the applicable range (eg, tax rate = -50%) -This may produce a result but it will be incorrect or nonsensical. It may crash the program unless caught
§Of the wrong type (eg, tax rate = "fred the camel") -This is very likely to crash the program unless caught and any results will be meaningless.
Usually if invalid data is input by the user we should give the user a warning and move on.
If the invalid data is supplied by another programmer (because we are writing code to put in a library) then there are several choices:
§Return some kind of signal value that their program could detect (but we need to choose a suitable value and they need to know how to allow for it)
§Controlled crash (this warns the other programmer that they are using the library wrong and puts the onus on them to add validation if it's appropriate)
§Return an arbitrary value (this usually only applies in performance critical code
where checking the validity of the input would take substantial time, or where the function may be called multiple times on the same values meaning that checking them over and over is a waste of time)
§We may want to test our software by asking users to interact with it. ceptance testing? §This is often done for testing non-technical properties such as user friendliness, or subjective ones such as performance. §Usually has to be done with care as it can be expensive and take time to involve users.
asking the user to enter a new value if they entered an invalid one is not considered user friendly on modern systems.
§Stop the program completely §Change their answer to a previous question §Get more explanation about the range
-Some development systems allow us to set up tests that run automatically.
-When we tell the program to run tests it automatically runs a series of tests and reports the results
-Source code inspection is not technically a form of testing, but it can prevent problems in the same way.
-Having someone else, or an automated system, examine the source code for potential errors or suspicious sections.
Most IDEs now perform some source inspection automatically while the program is being typed. This can detect things like:
-Variables not being initialized;