Testing

Steven Zeil

Last modified: Jan 5, 2017
Contents:
1 The Testing Process
1.1 The Steps in a Testing Process
2 Stages of Testing
3 Unit Testing
3.1 Scaffolding
4 Integration Testing

1 The Testing Process

 

The diagram here illustrates the steps involved in testing code.


Terminology

Related to these, though not part of our testing process:

1.1 The Steps in a Testing Process

 

A test plan (more properly, a test specification) describes a set of test cases.

  1. Derive inputs for each test case.

    In most cases, you will also need to record the expected outputs or behavior for your test inputs.

    The inputs and expected outputs may be recorded in a database of regression tests for later. But the most obvious use for the new inputs is to…

  2. Execute the tests

    The test inputs are fed into the program being tested and the actual outputs collected.

  3. Determine which tests have failed.

    The test inputs, actual outputs obtained from their execution, and the expected outputs are passed on to the testing oracle. The oracle is the person, program, or process used to determine if a test has failed.

  4. Pass the failures on for debugging.

    The purpose of debugging is to determine the faults i nthe code that are actually responsible for the failures observed during testing.

1.1.1 Oracles

The testing oracle is the person, program, or process used to determine if a test has failed.

Common oracles:

1.1.2 Regression

The regression log or regression database is a collection of tests and expected outputs from past testing.

It is used, during regression testing, to quickly rerun old tests. Regression databases can quickly grow to thousands or tens of thousands of cases or more. It becomes particularly important that we not rely on the eyeball oracle for evaluating regression tests.

2 Stages of Testing

We recognize several different stages of testing. These differ in scope (how much of the program is involved) and purpose (who conducts the testing and what information do they derive from it).


Testing goals

Focusing on the differing purposes of testing, …


Regression testing is particularly interesting. We regression test after a change to make sure we have not inadvertently broken anything else. In fact, we really are looking for unintended effects of our changes.

So, while most testing has possible outcomes “pass” or “fail”, regression testing has outcomes

3 Unit Testing

We’re going to spend a lot of time taking about unit testing this semester, so it deserves some special attention now.

By testing modules in isolation from the rest of the system

Main challenge is how to test in isolation

3.1 Scaffolding

To do Unit tests, we have to provide replacements for parts of the program that we will omit from the test.

3.1.1 Drivers

A driver is test scaffolding that calls the module being tested.

3.1.2 Stubs

Stubs are replacements for code begin called from the unit under test

4 Integration Testing

Integration testing is testing that combines several modules, but still falls short of exercising the entire program all at once.

It’s worth noting that unit testing and integration testing can sometimes use some of the same test inputs (and maybe the same expected outputs), because we are testing the software in different configurations.