jgs CSC 309 Software Engineering II Lecture 18: Test Driven Development Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227 Office Hours: By appointment
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 7 1. Create a GUI 2. Develop a Lexer that splits and classifies words 3. A parser method for method 4. A parser method for local variables 5. A parser method for instructions 6. A parser method for input/output (println) 7. A parser method for the if condition 8. A parser method for the for loop 9. Test Cases for Lexer 10. Test Cases for Parser Issues
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 10 Definition Testing a unit - the smallest piece of code that can be logically isolated in a system. (a method in Java)
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 11 Definition TDD suggests that the code is developed or changed exclusively on the basis of Unit Testing.
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 19 § You cannot test every possible input, parameter value, etc. So, you must think of a limited set of tests likely to expose bugs. § Think about boundary cases positive; zero; negative numbers right at the edge of an array or collection's size § Think about empty cases and error cases 0, -1, null; an empty list or array § Test behavior in combination maybe add usually works but fails after you call to remove make multiple calls; maybe the size fails the second time only Tips for Testing
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 20 § Test one thing at a time per test method. 10 small tests are much better than 1 test 10x as large. § Each test method should have a few (likely 1) assert statements. If you assert many things, since the first that fails will stop the test, you won't know whether a later assertion would have failed. § Torture tests are okay, but only in addition to simple tests. Trustworthy tests
jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 | 22 Office Hours Tuesday and Thursday 3 - 5 pm But an appointment required Sent me an email – [email protected]
jgs CSC 309 Software Engineering II Lab 18: Test Driven Development Dr. Javier Gonzalez-Sanchez [email protected] Building 14 -227 Office Hours: By appointment
jgs CSC 309 Software Engineering II Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2023 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.