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

CSC307_L99_TDD.pdf

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 CSC307_L99_TDD.pdf

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 307 Introduction to Software Engineering Lecture. Test Driven Development
  2. 2 Testing Matters • Softw a re bugs a re

    expensive • M a nu a l testing does not sc a le • Regression issues a ppe a r frequently • Tests provide con f idence during ref a ctoring • Softw a re engineering relies on a utom a tion
  3. 3 Test-Driven Development (TDD) • Tests a re written before

    implement a tion • Tests a ct a s "execut a ble requirements" • Focus on beh a vior a nd correctness • Encour a ges modul a r a nd m a int a in a ble design
  4. 4 Process • Write a f a iling test •

    Implement minim a l code to p a ss • Improve design s a fely (ref a ctor) • Repe a t continuously during development
  5. 6 JUnit Basics • JUnit is the st a nd

    a rd J a v a testing fr a mework • Tests a re written a s J a v a methods • Assertions verify expected beh a vior • Tests should be isol a ted a nd repe a t a ble @Test • Set up your objects • Execute behavior • Assert // assertEquals(expected, // actual) // assertTrue(condition) // assertThrows(exception, code)
  6. 7 Maven • src/m a in/j a v a →

    Applic a tion code • src/test/j a v a → Test code • pom.xml → Dependencies a nd build con f igur a tion • mvn test → Execute a utom a ted tests • Maven automatically discovers test classes • JUnit tests execute during the build process • Builds fail if tests fail
  7. 9 1. Interfaces • Interf a ces de f ine

    expected beh a vior • Developers implement concrete cl a sses • Tests v a lid a te correctness a utom a tic a lly
  8. 15 Common Mistakes • H a rdcoding outputs • L

    a rge complex test methods • Not underst a nding requirements • Poor Git commit pr a ctices
  9. 17 Continuous Integration (CI) • Autom a tic a lly

    builds a nd tests softw a re • Triggered on every commit or pull request • Detects problems e a rly
  10. 18 GitHub Actions • GitHub Actions a utom a tes

    work f lows • Runs M a ven tests in the cloud • Provides p a ss/f a il feedb a ck • Integr a ted directly with GitHub repositories
  11. CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Winter 2026 Copyright. These slides can only be used as study material for the class CSC307 at Cal Poly. They cannot be distributed or used for another purpose.