Finally, the well deserved break. As this pandemic forces me to work from home for too many days now, I treasure every moment I can walk in the open. So I grab a lunch out of my kitchen and step outside. Breathing in the fresh outdoor air, I try to let go of all tension. Tomorrow I’ll have to give a presentation to my fellow programmer buddies. And to be honest, I am quite stressed about this. How should I convey my message? Yeah, I made some slides. But still, will they really understand it? How can I even get them to stay focussed all the time? Especially now I have to do present remotely.
Archive: November 2021
The Gradle Build Cache is particularly well suited to speed up your CI/CD build times. But to set it up properly in GitLab you need to get a few things exactly right. This blogpost will guide you through the steps, as well as provide you with some background.
We’ll go through the steps necessary to parse value classes.
Testing classes that work with date calculations based on the current date and time (now) can be difficult. First of all we must make sure our class under test accepts a
java.time.Clock instance. This allows us to provide a specific
Clock instance in our tests where we can define for example a fixed value, so our tests don’t break when the actual date and time changes. But this can still not be enough for classes that will behave different based on the value returned for now. The
Clock instances in Java are immutable, so it is not possible to change the date or time for a
In Spock 2.0 we can use the new
MutableClock class in our specifications to have a
Clock that can be used to go forward or backward in time on the same
Clock instance. We can create a
MutableClock and pass it to the class under test. We can test the class with the initial date and time of the
Clock object, then change the date and time for the clock and test the class again without having to create a new instance of the class under test. This is handy in situations like a queue implementation, where a message delivery date could be used to see if messages need to be delivered or not. By changing the date and time of the clock that is passed to the queue implementation we can write specifications that can check the functionality of the queue instance.