tailieunhanh - Lecture Programming principles and practice using C++: Chapter 26 - Bjarne Stroustrup
This lecture is an introduction to the design and testing of program units (such as functions and classes) for correctness. We discuss the use of interfaces and the selection of tests to run against them. This chapter emphasize the importance of designing systems to simplify testing and testing from the start. Proving programs correct and performance problems are also briefly considered. | Chapter 26 Testing Bjarne Stroustrup Abstract This lecture is an introduction to the design and testing of program units (such as functions and classes) for correctness. We discuss the use of interfaces and the selection of tests to run against them. We emphasize the importance of designing systems to simplify testing and testing from the start. Proving programs correct and performance problems are also briefly considered. Stroustrup/Programming Overview Correctness, proofs, and testing Dependencies System tests Testing GUIs Resource management Unit and system tests Finding assumptions that do not hold Design for testing Performance Stroustrup/Programming Correctness Questions to ask about a program Is your program correct? What makes you think so? How sure are you? Why? Would you fly in a plane that depended on that code? You have to be able to reason about your code to have any real certainty Programming is generally unsystematic . | Chapter 26 Testing Bjarne Stroustrup Abstract This lecture is an introduction to the design and testing of program units (such as functions and classes) for correctness. We discuss the use of interfaces and the selection of tests to run against them. We emphasize the importance of designing systems to simplify testing and testing from the start. Proving programs correct and performance problems are also briefly considered. Stroustrup/Programming Overview Correctness, proofs, and testing Dependencies System tests Testing GUIs Resource management Unit and system tests Finding assumptions that do not hold Design for testing Performance Stroustrup/Programming Correctness Questions to ask about a program Is your program correct? What makes you think so? How sure are you? Why? Would you fly in a plane that depended on that code? You have to be able to reason about your code to have any real certainty Programming is generally unsystematic Debugging is generally unsystematic What are you willing to bet that you found the last bug? Related interesting questions Could the program run forever if the hardware didn’t fail? Does it always deliver its results in a reasonable time? Stroustrup/Programming Proofs So why not just prove mathematically that our program is correct? It’s often too hard and/or takes too long Sometimes proofs are wrong too (even proofs produced by computers or by experts!). Computer arithmetic isn’t the same as “real” math—remember the rounding and overflow errors we saw (due to finite and limited precision)? So we do what we can: follow good design principles, test, test, and then test some more! Stroustrup/Programming Testing “A systematic way to search for errors” Real testers use a lot of tools Unit test frameworks Static code analysis tools Fault injection tools When done well, testing is a highly skilled and most valuable activity “Test early and often” Whenever you write a function
đang nạp các trang xem trước