How Do Test-Driven and Behavior-Driven Development Build Better Software?
Learn why writing code before writing tests instantly creates legacy debt, and how the red-green-refactor loop eliminates late-night production debugging.
Session Questions
- Could you give a brief intro about yourself and your professional background?
- What are you going to share regarding TDD and BDD today?
- What exactly is test-driven development and who is it intended for?
- Why does software degrade over time when tests are not written first?
- How does the mindset shift when moving to test-driven development?
- Should developers write both the code and the unit tests themselves?
- What are the top reasons developers resist adopting TDD?
- Why do managers sometimes hesitate to encourage TDD or BDD?
- What is your final advice for developers planning to use TDD and BDD?
The Core Argument
Guided by host Sanjay Saini, Agile Coach Murali Mohan argued that writing code before writing tests is the primary reason software degrades into unmaintainable, rigid legacy systems. Adopting Test-Driven Development (TDD) forces developers into short, 30-second feedback loops of writing failing tests, fixing them, and refactoring. While developers often resist TDD due to a fear of decreasing velocity, Murali emphasized that this initial dip is heavily outweighed by the long-term reduction in bugs and maintenance costs. By integrating Behavior-Driven Development (BDD), product owners and testers collaborate upfront, ensuring quality is built into the product rather than tested into it after the fact.
“Code without test is legacy code. We write code without tests and make it legacy.” Murali Mohan (11:32)
Detailed Answers
1. Could you give a brief intro about yourself and your professional background?
Murali brings decades of experience to the table, starting his software career in 1995 building C++ and ASP.NET applications. He transitioned into Agile workflows around 2010 at GE Energy and eventually served as an Agile Coach for Renault Nissan for six years. After retiring from his corporate role, he pivoted to become a full-time trainer, actively teaching SAFe product ownership and advocating for extreme programming practices.
2. What are you going to share regarding TDD and BDD today?
Murali wishes he had known about TDD back when he started coding in 1992. He planned to demonstrate how TDD and BDD actively eliminate the late-night, frustrating debugging sessions developers face. By fundamentally shifting testing to the absolute beginning of the cycle, these extreme programming practices smooth out the entire development lifecycle.
3. What exactly is test-driven development and who is it intended for?
Test-Driven Development is a software engineering practice strictly meant for developers, not QA testers. It relies on extremely short, disciplined development cycles of 30 to 90 seconds. Developers take system requirements, turn them into tests, and then develop the actual software to ensure those tests pass, maintaining constant alignment with the business logic.
4. Why does software degrade over time when tests are not written first?
When teams write massive amounts of code without accompanying tests, the software becomes legacy code immediately. Over time, as original architects leave and new developers arrive, they fail to understand the core intent. This leads to duplicate code, extreme rigidity, and the constant fear that modifying one feature will catastrophically break another system.
5. How does the mindset shift when moving to test-driven development?
In traditional environments, developers write thousands of lines of code and then attempt to write tests after the fact. The TDD mindset completely reverses this: developers write a failing test first when no production code exists. They then write just enough code to make that specific test pass, following a strict "red, green, refactor" cycle.
6. Should developers write both the code and the unit tests themselves?
Yes, developers must write their own unit tests. While testers should be heavily involved in writing UI automation tests (like Selenium) and collaborating on BDD scenarios, unit tests sit at the absolute bottom of the testing pyramid. They are fast, inexpensive, and must be completely owned by the developers who are actually writing the syntax.
7. What are the top reasons developers resist adopting TDD?
The primary reason developers avoid TDD is fear. Teams are terrified that writing tests first will permanently reduce their delivery velocity, causing stakeholders to complain. Murali advises teams to expect a dip in velocity during the first three sprints, but emphasizes that the massive improvement in stability and quality completely offsets the initial slowdown.
8. Why do managers sometimes hesitate to encourage TDD or BDD?
While some managers fear temporary drops in velocity, Murali found that once managers see the long-term benefits, they become highly supportive. BDD acts as a massive collaborative bridge, taking acceptance criteria out of isolated Jira tickets and turning them into shared, automated scenarios agreed upon by testers, developers, and product owners before code is ever written.
9. What is your final advice for developers planning to use TDD and BDD?
BDD is one of the easiest frameworks to adopt because it simply requires cross-team collaboration to write "given/when/then" acceptance criteria. TDD, however, requires conscious, disciplined practice. Once a developer masters the red-green-refactor loop, they will never want to return to their old ways of late-night, manual debugging.
Murali's advice to shift testing to the left is essential for technical agility. Learn how to align your product ownership and technical delivery teams in our Agile and Scrum Certification Courses.
“You don't have to keep on pressing F7 and F7 and then debugging till 2 AM.” Murali Mohan (47:10)
About the Guest
Murali Mohan is an Agile Coach and Technical Trainer with a software engineering career dating back to 1995. Having spent years developing C++ and ASP.NET applications, he transitioned to Agile workflows and served as an Agile Coach for Renault Nissan for six years. He now focuses full-time on training teams in Extreme Programming practices and technical agility.
Connect on LinkedIn
About the Host
Sanjay Saini is the founder of AgileWoW and a leading Agile transformation expert. He hosts the AgileWoW live session series, bringing in industry experts to discuss the practical realities of modern framework adoption and the future of work.
Connect on LinkedInStop Debugging Legacy Code
Writing code without tests instantly generates technical debt. Our certification programs teach product owners, developers, and Scrum Masters how to enforce extreme programming practices like TDD and BDD to build software that can survive changing requirements.
Explore Certification Courses