Your code always does what you type—unit tests will assert that it does what you actually meant. As you develop your application, unit testing further helps ensure your code continues to meet your expectations.
Learning to write unit tests in Scala will benefit you in a number of ways:
It’s a nice way to introduce Scala on your current projects. Even though your production code may be in Java, you can write the test code in Scala.
It’s a good way to learn Scala itself. As you learn the language, you can experiment with the language and its API by writing test cases.
It improves your design. It’s very hard to unit test large and complex code. In order to test it, you’d end up making the code smaller. This will lead to ...