October 2018
Intermediate to advanced
982 pages
23h 29m
English
The smallest scoped tests we can write are referred to as unit tests. In fact, people have been writing tiny tests for years. A common paradigm is to try and test just one class in a given unit test.
To get going, let's test the smallest unit of code we have: our Lombok-enabled Image domain object.
As a reminder, here is what that code looks like:
@Data
@Document
public class Image {
@Id final private String id;
final private String name;
}
This tiny little POJO is flagged with Spring Data MongoDB annotations as well as Lombok's @Data annotation providing getters and setters.
A unit test shouldn't be too hard. We can start by creating ImageTests.java in /src/test/java, and in the same package as the original class (com.greglturnquist.learningspringboot ...
Read now
Unlock full access