Tag Archives: library

Better Test Code Principles: #3 Use external libraries when available

Most of the testing tasks require some data processing, whether it is working with JSON objects, gathering data from a database, processing Strings, working with date types, and so on. Performing the processing requires some code to be written, apart from the tests themselves. But why write that code yourself, if it already exists in an easily usable external library? Continue reading Better Test Code Principles: #3 Use external libraries when available

Advertisements

Working with lists: ImmutableList

When you are faced with a task that involves using lists, you might want to consider the following question: are the elements in my list ever going to change, or is it enough to just add my elements to the list once and use them across my tests. Is my list a constant? In case your elements will not change, you can use an ImmutableList to store them, which brings a major advantage: defining a list in one line. ImmutableList is part of the ‘guava’ library. Continue reading Working with lists: ImmutableList