In two previous posts, I wrote about how to test the persistence layer against a Dockerized database and how to test a Java EE application combined with a database both running in a Docker container. Both posts were backend-centric, this one is on the frontend side.
If you are new to Docker or Testcontainers I recommend reading the first post in this series in which Testcontainers gets explained a bit more in detail.
In a previous post, I described how to test the Hibernate layer with Docker. This article carries this idea a step further by deploying the complete application to a Dockerized Wildfly server. The example application needs a MariaDB, which is installed in the same Docker image as the Wildfly server.
The big benefit is that those integration tests feel like unit tests because they are completely self-contained. They can be run from the IDE as well as on the integration server without having a local application server or database server and without all those local machine-wise configurations. The only precondition…
Did you ever feel the need to write unit tests for your persistence layer? We know logic doesn’t belong there, it should just do some CRUD operations and nothing more. But in reality some kind of logic can be found in the most persistence layers. Some use heavy native SQL, some others make use of the Criteria API which is test-worthy because of it’s complex syntax.
We are all writing unit tests for the service layer but the persistence layer in contrast is rarely tested as it is more complicated to test SQL or JPQL or any other QL’es.
One drawback of GitLab compared to GitHub are the missing third party services like Travis CI or Coveralls. On GitLab we have GitLab CI. On first sight it is very powerful as you can define a docker container in which your application gets deployed and tested.
For Java the documentation isn’t very verbose at the moment, it is hard to find good examples. This article may be one.
To test a Java application you can use one of the official java images. …
Software Engineer who likes quality