O'Reilly logo

Introduction to JVM Languages by Vincent van der Leun

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a dummy implementation of the method

To be able to write a unit test, we need to write a method that follows the method signature requirements (input and output), but we will just let it return null. By doing this, we can write a unit test, see it fail, and then provide the correct implementation and see the test succeed.

If you study the business rules closely, you'll find that you have to write a method that would take an input and generate a response. The method has to be self-contained; it does not seem to require any class instance variables or methods. We, therefore, will choose to write a static class method. During the coding of the unit test, we can determine whether this was a bad choice. If so, we can always change it ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required