a Chinese writer

Discussion 4: Questions about Testing in Software Development

Why do we want to test a program?

Without testing, we cannot be certain that the program works correctly and fully as intended.

A program consists of a set of instructions that must be executed in a specific sequence, known as an algorithm. Writing correct algorithms for real-world problems can be challenging and prone to error. Testing helps us catch these errors early, improve the quality of the software, and increase confidence that the system meets its goals.

What does it mean to test a program?

According to the reading, the programming process usually involves ten steps. Testing a program means each step should be carefully verified before moving on to the next one, especially steps 6 through 9. Skipping steps is not recommended, even for seemingly simple programs. Each step should be reviewed, problems fixed, and the final output verified. In fact, programming is itself a process of continuous testing.

In particular, testing means verifying that the program behaves as expected for a variety of input cases, including normal, boundary, and invalid inputs.

How is testing accomplished?

Testing is accomplished through ten steps, especially steps 6 through 10. These include entering the source code into a file, compiling it, designing test cases, executing test data, and repeating steps 6 through 8 as many times as needed. These cycles continue until the program performs as intended and passes validation. Testing may involve both manual testing and automated testing methods to cover a broad range of scenarios efficiently.

When should it be done?

Testing should be done throughout the development lifecycle, not just after coding is complete. Early testing helps catch errors sooner, reducing the cost and effort required to fix them. Testing should also occur right before the program is deployed to users, as well as during later maintenance updates. Frequent and early testing improves software quality and stability.

Can we prove without a doubt that a program is correct?

While we can gain confidence in a program’s correctness by testing its outputs, we cannot prove it is entirely correct in all cases. The absence of compiler errors does not guarantee logical correctness. Only thorough testing with different inputs can help validate expected behaviour. Although step 8 mentions “choose sample test values for ‘all’ possible combinations of input”, it is not feasible to test every combination in real-world programming. Therefore, testing helps us reduce the risk of errors but cannot absolutely guarantee a program is error-free in every possible situation.

References:

Reading material

zyBooks

“Software Engineering” by Ian Sommerville (10th Edition)

ACM / IEEE Joint Curriculum Guidelines for Computer Science

“The Pragmatic Programmer” by Andrew Hunt and David Thomas

留下评论