Sunday, April 28, 2019

Annotate - simple yet productive screenshots tool for macOS

After switching from Windows to macOS I was looking for a simple screenshots taking tool to support my daily workflow. The built-in tools offered by macOS are not sufficient for me, mainly because of the image annotating tools and limited keyboard shortcuts support. For couple of days I used Skitch, but then I found Annotate, a light-weight and simple app with quite good keyboard shortcuts support. In this short blog post, I share how I currently work with Annotate app.

Sunday, March 24, 2019

Test Execution Order in JUnit 5

The general practices say that automated tests should be able to run independently and with no specific order as well as the result of the test should not depend on the results of previous tests. But there are situations where a specific order of test execution can be justified, especially in integration or end to end tests.

By default, in JUnit 5 the execution of test methods is repeatable between builds hence deterministic but the algorithm is intentionally non-obvious (as authors of the library state). Fortunately, execution order can be adjusted to our needs using either built-in method orderers or by creating custom ones.

Sunday, March 17, 2019

Temporary directories in JUnit 5 Tests

JUnit 4 TemporaryFolder @Rule allowed developers to create tests utilizing temporary directories. With JUnit 5, the @Rules are not supported hence testing files and directories requireds a little bit of additional work. Fortunately, with JUnit 5.4 there is a new built-in extension to handle temporary directories in tests. And it is extremely easy to use.

Thursday, November 23, 2017

JUnit 5 meets AssertJ

JUnit 5 brings a lot of improvements in the assertions library, mainly thanks to Java 8 and Lambda Expression support and thanks to the presence of the new assertions like assertAll, assertTimeout orassertThrows. Although I really like JUnit 5 I believe that AssertJ is still a must in production grade unit tests and I will continue using it.

But I think there are potential scenarios of mixing both JUnit 5 and AssertJ in single unit test: one of them is mixing JUnit assertAll with AssertJ assertThat.

Friday, October 6, 2017

Asynchrouns and Transactional Event Listeners in Spring

The built-in event publication functionality exists from the early Spring versions and it is still useful for handling basic communication between Spring components in the same application context. In general, the application can generate application events (that can be arbitrary objects) and listen to them. The whole mechanism is really simple: using ApplicationPublisher you publish events and using EventListener you handle them. What I find especially useful is asynchronous and transactional event listeners.

Thursday, October 5, 2017

JUnit 5 - Quick Tutorial

JUnit 5 is the next generation unit testing framework for Java equipped with many interesting features including nested tests, parameterized tests, new extension API or Java 8 support to mentioned a few.

This article shows basic concepts of JUnit 5 including test lifecycle, parameter injection and assertions (basic, timeout and exception).

Tuesday, October 3, 2017

Spring Boot - - Case Study

Externalizing Spring Boot application properties is useful when the same application code must be used with different configuration. If the configuration is to be kept away from the source code (which is considered a best practice anyways)spring.config.location environment property can be used to point the directory location with properties files for example. On the other hand, can be used to change the base name of the properties file which defaults to application. The documentation reads: if you don’t like as the configuration file name you can switch to another. But in what scenario could be used?