
上QQ阅读APP看书,第一时间看更新
Writing unit tests in a different language
It is quite a common approach to test Java code with unit tests written in a different language. As we have seen earlier in this chapter, the code in other languages can be much more compact than the same code in Java, which is ideal for writing small, concrete, and readable unit tests.
Since the language's runtime library will only be used while running the unit tests, the language's runtime library itself will only be used while executing the tests and it will not have to be bundled with the compiled main project.
Groovy is especially suited for this use case, as we will see in the Chapter 11, Groovy. It has some convenient features for writing unit tests, including a built-in assert statement that prints very verbose and readable output when the passed value is different than the expected output.