Skip to main content
Engineering LibreTexts

1.6: Software Testing

  • Page ID
    10602
  • Overview

    Software testing involves the execution of a software component or system component to evaluate one or more properties of interest. In general, these properties indicate the extent to which the component or system under test:[1]

    • meets the requirements that guided its design and development
    • responds correctly to all kinds of inputs
    • performs its functions within an acceptable time
    • is sufficiently usable
    • can be installed and run in its intended environments
    • achieves the general result its stakeholders desire

    Discussion

    Test data consists of the user providing some input values and predicting the outputs. This can be quite easy for a simple program and the test data can be used twice.

    1. to check the model to see if it produces the correct results (model checking)
    2. to check the coded program to see if it produces the correct results (code checking)

    Test data is developed by using the algorithm of the program. This algorithm is usually documented during the program design with either flowcharting or pseudocode. Here is the pseudocode in outline form describing the inputs, processing, and outputs for a program used to calculate gross pay for hourly work.

    Pseudocode using an IPO Outline for Calculating Gross Pay

    Input
        display a message asking user for their hours worked
        get the hours from the keyboard
        display a message asking user for their pay rate
        get the rate from the keyboard
        
    Processing
        calculate the gross pay by:
            multiplying the hours worked by the hourly rate
    
    Output
        display the gross pay on the monitor
        pause so the user can see the answer

    Creating Test Data and Model Checking

    Test data is used to verify that the inputs, processing, and outputs are working correctly. As test data is initially developed it can verify that the documented algorithm (pseudocode in the example we are doing) is correct. It helps us understand and even visualize the inputs, processing, and outputs of the program.

    Inputs: I worked 37.5 hours this week and my hourly rate is $15.50 per hour. We should verify that the pseudocode is prompting the user for this data.

    Processing: Using my solar powered handheld calculator, I can calculate the gross pay would be: 37.5 * 15.50 or $581.25. We should verify that the pseudocode is performing the correct calculations.

    Output: Only the significant information (total gross pay) is displayed for the user to see. We should verify that the appropriate information is being displayed.

    Testing the Coded Program – Code Checking

    The test data can be developed and used to test the algorithm that is documented (in our case our pseudocode) during the program design phase. Once the program is code with compiler and linker errors resolved, the programmer gets to play user and should test the program using the test data developed. When you run your program, how will you know that it is working properly? Did you properly plan your logic to accomplish your purpose? Even if your plan was correct, did it get converted correctly (coded) into the chosen programming language? The answer (or solution) to all of these questions is our test data.

    By developing test data we are predicting what the results should be, thus we can verify that our program is working properly. When we run the program we would enter the input values used in our test data. Hopefully, the program will output the predicted values. If not then our problem could be any of the following:

    1. The plan (IPO outline or another item) could be wrong
    2. The conversion of the plan to code might be wrong
    3. The test data results were calculated wrong

    Resolving problems of this nature can be the most difficult problems a programmer encounters. You must review each of the above to determine where the error is lies. Fix the error and re-test your program.

    Key Terms

    code checking
    Using test data to check the coded program in a specific language (like C++).
    model checking
    Using test data to check the design model (usually done in pseudocode).