Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC309 Lecture 18

CSC309 Lecture 18

Software Engineering II
Test Driven Development
(202305)

Javier Gonzalez-Sanchez

February 23, 2023
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. 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
  2. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    3 § Final Exam Wednesday, June 14 at 1:10 pm https://registrar.calpoly.edu/spring-final-exam-schedule § Final Project Friday, June 09 (lecture Time) § Academic Holiday Monday, May 29 (lecture Time) § Project Status Report 3 Friday, May 26 (lecture Time) Schedule
  3. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    5 int x; void student () { world(); for (int x=0; x<10; x++) { hello(); x = x + 1; break; } } Case 4 Input: Output:
  4. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    6 Objects Begin End Call a method Instruction Input or Output Variable declaration Condition
  5. 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
  6. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    9 Key Ideas CSC 309 idea requirements architecture design code unit testing quality measure
  7. 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)
  8. 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.
  9. 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
  10. 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
  11. 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]
  12. jgs

  13. jgs CSC 309 Software Engineering II Lab 18: Test Driven

    Development Dr. Javier Gonzalez-Sanchez [email protected] Building 14 -227 Office Hours: By appointment
  14. jgs Javier Gonzalez-Sanchez | CSC 309 | Winter 2023 |

    26 Scenario Box Name1 Name2 class Name1 { } class Name2 { method(){ Name1 Cat } } class Cat extends Name1 { } Cat
  15. 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.