Being able to define extension functions to classes that belong to third-party libraries looks very nice at the first point. However, they might become a road blocker during your unit testing, if you are working with Mockito as the mocking library. Let’s talk about the problem using an example, let’s write an extension function to […]
What is this SELF in GenericContainer For?
GenericContainer class belongs to TestContainers library, which is used to create a container instance, launch and control it during integration testing. All other TestContainers classes, like MySQLContainer, KafkaContainer, etc, extend from this base class. However, it has a bit weird generic class definition itself as you may notice from below code block. This somehow recursive […]
TestContainers & MySQL Setup Notes
Integration tests are one of the fundamental building blocks of the testing pyramid. By using integration tests, we try to verify if our software components interact with each other and with its third-party external dependencies according to the requirements of the software being written. One type of those external dependencies is called generic third-party dependencies, […]
EmbeddedRedis Support For Spring Framework
When I was working on one of our microservice projects, I’ve come up with a nice project which help us to run a Redis Server as embedded within our Java integration tests. Actually, by using such a library, it becomes very easy to start and stop a Redis server instance within the test methods. However, […]
Weird Rollback Behavior of Spring TestContext Framework
One of the nice features of TestContext module of Spring Application Framework is its ability to run unit tests within a transaction context. By that way, you are able to both execute your persistence operations which usually expect an active transaction to run, and also rollback state changes occur during execution of these persistence operations […]
Integrating JSFUnit To Your Project
Actually I am not a big fun of in-container unit testing approaches. They have longer execution times, e.g. container and database startup, intialization times etc. In addition, they create configuration complexity in terms of packaging of tests and deployment of application together with them. Anyway, recently I needed to examine JSFUnit solution more closely for […]
Run all TestNG tests with just one click inside Eclipse
It is a little bit annoying if you have looked around in eclipse and tried to find a short cut to run all of your tests using TestNG with one mouse click. One way of running TestNG tests is with creating a testng.xml file and defining tests in it. There are several options to define […]
If you want to unit test a method that depends java.util.ResourceBundle, and want to isolate bundle access code with mocking ResourceBundle, using for example, JMock Dynamic Mocking Library, you will face with a restriction, that commonly used methods, such as getString(key) are defined as final in ResourceBundle class. There is no way to extend and […]
Cactus XOR Mocks or Cactus AND Mocks?
We employ both Spring and Hibernate to implement business and data access layers in our current project. Our aim is to bring clear separation between those two layers. Beans in business layer act as service entry points. They simply realize our use case scenarios. They are also good candidates as start and end points for […]