Running Parallel Tests in Docker

Sometimes when you are running your tests on your CI environment, you want to run tests in parallel. This parallelism is programmed in build tool such as Maven or Gradle or by using Jenkins plugin. If you are using Docker as a testing tool for providing external dependencies to the application (for example databases, mail servers, ftp servers, ….) you might find a big ...

Read More »

Effective Java – Creating and Destroying Objects

Creating and Destroying Objects (Ch 2) This is a short summary of Joshua Blochs book Effective Java chapter 2. I have only included items that are relevant for myself. Static Factories (item 1) Some advantages of static factories vs constructors: Factory methods have names which add a description to the constructor They can return pre-constructed object instead of always returning ...

Read More »

Effective Java – Method Common to All Objects

Methods Common to All Objects (Ch 3) This is a short summary of Joshua Blochs book Effective Java chapter 3. I have only included items that are relevant for myself. The general equals() contract (item 8) The equals contract describes the equivalence relation as: x.equals(null) == false Reflexive – x.equals(x) == true Symmetric – if x.equals(y) == true then y.equals(x) ...

Read More »

Voxxed Days – Athens 2017 – short review #vdathens

Yesterday I had the pleasure to attend the very first Voxxed Days Athens. As I have written 6 months ago while attending Voxxed Days Thesalloniki, this was the day I’ve waiting for too many years, a  proper conference, with top class speakers on the main IT hub of Greece, Athens. Once again, congrats to Patroklos Papapetrou and the team around Voxxed Athens, at ...

Read More »

Mocking Spring Security Context for Unit Testing

spring-interview-questions-answers

Today, while writing unit test case for one of the Java method which looks like below: public ApplicationUser getApplicationUser() { ApplicationUser applicationUser = (ApplicationUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); return applicationUser; } I want to mock Spring Security Context to get the Principal, to achieve the same I mocked each level of method calls as follows: import org.junit.Before; import org.junit.Rule; import org.junit.Test; import static org.mockito.Mockito.when; ...

Read More »

Boosting test performance with TestContainers

java-interview-questions-answers

In my previous post on testing, I described how to use TestContainers to provide realistic test environments for database tests. This comment revealed the downside: …as noted above, there always seems to be some drawback. In this case, the overhead of starting the Docker image and everything it contains will increase your overall build time. As a reminder, here’s the ...

Read More »

Kotlin and Android: JetBrains and Google Behind One Language

Google I/O 2017 had several major announcements, but one of the most interesting to me is “first-class support for Kotlin” on Android. The Kotlin blog post on this announcement discusses the benefits this brings to Kotlin users: In case you are concerned about other platforms that Kotlin supports (Kotlin/JVM for server and desktop, Kotlin/JS and Kotlin/Native), please be sure that ...

Read More »

Single Statement Unit Tests

Many articles and books have already been written about unit testing patterns and anti-patterns. I want to add one more recommendation which, I believe, can help us make our tests, and our production code, more object-oriented. Here it is: a test method must contain nothing but a single assert.             Look at this test method ...

Read More »