Test-Driven Development Learn the "Test First" Approach to Coding Svetlin Nakov Technical Trainer Software University
Code and Test vs. Test Driven Development
3 "Code First" (code and test) approach Classical approach "Test First" approach Test-driven development (TDD) Unit Testing Approaches
Code and Test Approach 4 Write code Write unit test Run and succeed Time flow
TDD in One Slide 5
Test-Driven Development (TDD) 6 Pick а test Compile and fail Write code to pass test Write enough code to compile Run test and fail Create a test list Time flow Write test Remove duplication
7 TDD helps find design issues early Avoids rework Writing code to satisfy a test is a focused activity Less chance of error Tests will be more comprehensive than when written after code Why TDD?
8 You create a 100% regression test suite The unit tests form 100% of your design specification You only need to unit test TDD is sufficient for testing TDD doesn't scale (partially true) Your test suite takes too long to run Not all developers know how to test Everyone might not be taking a TDD approach Myths and Misconceptions
Test-Driven Development Live Demo: Poker Hands Checker
? ? ? ? ? ? ? ? ? Test-Driven Development
License This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" licenseCreative Commons Attribution- NonCommercial-ShareAlike 4.0 International 11 Attribution: this work may contain portions from "High Quality Code" course by Telerik Academy under CC-BY-NC-SA licenseHigh Quality CodeCC-BY-NC-SA
Free Software University Software University Foundation – softuni.orgsoftuni.org Software University – High-Quality Education, Profession and Job for Software Developers softuni.bg softuni.bg Software Facebook facebook.com/SoftwareUniversity facebook.com/SoftwareUniversity Software YouTube youtube.com/SoftwareUniversity youtube.com/SoftwareUniversity Software University Forums – forum.softuni.bgforum.softuni.bg