Posts

Showing posts with the label tests

Spring Data JPA and H2

Image
Spring Data Spring Data makes persistence much easier. I personally not a huge fan of JPA and ORMs.  However, I know lots of engineers like it and I respect different preferences. Have different preferences in different services is totally fine. However, doing that in shared libs is NO-NO. Today I want to cover a bit more about how we can use Spring Data JPA and H2 database for testing. Speed matters. Combining H2 and MockMVC we can speed up tests considerably. I made a simple POC showing how we can configure and use Spring Data JPA with H2 and do proper testing using MockMVC capabilities. I also show how to use the H2 Console so we can query the database. Spring-Data makes persistence much more concise and leverages lots of common functionality for us. So Let's get started. 

AssertJ

Image
Everybody write tests or we should at least. Assertions are used in lots of different kinds of tests such as Unit Test, API Test, Integration Testing, E2E Testing, Contract Testing, Stress/Load testing. Unit tests, Integration, and Contract tests can often be done with Junit . However, assertions sometimes can be a bit verbose and you might need to write some extra code in order to test what you are required to test. Today I want to share a video about a library for Java called AssertJ. AssertJ is Assertions fluent API.  AssertJ has integration with other java libraries like Guava, JodaTime, and others. Today I want to share a video I made about it. So Let's get started.