What Is Test Driven Development (TDD)?
Do you like to play video games? Do you enjoy writing code? Then test-driven development is for you! TDD is a technique used in software development that uses tests as requirements. A test is written before writing any code, so when the new code passes the test, it's ready to be refactored into an acceptable standard. It's like playing a game with your computer. You write a test, and then your laptop runs it and tells you whether it works. If it doesn't work, you add some code for the test to pass and then refactor it until it's acceptable. The refactoring part can sometimes be as simple as shortening a variable name. Still, sometimes it involves changing how much memory each function call uses or something more complex. If you're going to write code, why wouldn't you want to have fun while doing it? TDD is like a game of chess. You set up the board, make your move, and then watch as your opponent does the same. You both take turns, trying to outsmart each other and win the match. There's one big difference between TDD and chess: with TDD, you can't cheat! That's because, with TDD, you have to write code only after it has been tested. That means that when you're working on a new feature, you can't just write code until it works—you have to write code until it passes the test! So if you want to go ahead and cheat by writing extra code before writing tests for it, good luck with that! TDD is great because it ensures your code is tested, which leads to standard and extensible code. It is always on writing only the code necessary to pass tests, so if something breaks down later in development, it's easy to fix because everything has been registered with such clear intent.
Related Terms by Computing
Join Our Newsletter
Get weekly news, engaging articles, and career tips-all free!
By subscribing to our newsletter, you're cool with our terms and conditions and agree to our Privacy Policy.