From the course: Test-Driven Development in Spring Boot with JUnit and Mockito

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Green phase: Implement the minimal code to pass the test

Green phase: Implement the minimal code to pass the test

From the course: Test-Driven Development in Spring Boot with JUnit and Mockito

Green phase: Implement the minimal code to pass the test

- [Instructor] And that brings us to the green phase. It will be a short one because it's such a simple example. I'll implement just enough code to make this test pass without worrying about the edge cases at all. So I'm going to update the divide methods. I'm going to say double result = a / b; and I'll return the result. Now, if I'm going to go in here and I run the test again, it passes, and that's great. We've turned our red test green, done with the green phase, but before we celebrate too much and move on to the next video already, I do want to spend a little time talking about a common mistake, trying to write all the tests for all the possible scenarios at once. So our next step, should we now write tests for division by zero, negative numbers, decimals, and so on? Nope. In TDD, we iterate step by step. We'd actually have to refactor first, so let's go ahead and do that in the next video.

Contents