Unit testing best practices

There are a lot of articles and blog posts written about unit testing best practices, patterns etc. Over the course of years after writing many varieties of unit test cases with and without mocking frameworks and reviewing many tests, there are few patterns that I have noticed many times again and again. For a change instead of writing about best practices I have compiled a list of testing bad practices to avoid.

Continue reading “Unit testing best practices”

Unit testing with Junit

How can a developer guarantee that the beautiful code they wrote would work as intended? By running unit tests on that code. This is the short answer. Unit tests should be well designed, easy to read and understand and more importantly easy to maintain. Unit tests should test all possible

Continue reading “Unit testing with Junit”

Using @ApiImplicitParams with Swagger 2

In the last post we saw how to use Swagger 2 with SpringFox and JAX-RS. Using annotations for methods usually pulls in all the parameters for that method. There may be certain instances where you may have to pass in extra header param for a method to work. Can we do that using Swagger 2 annotations?

Continue reading “Using @ApiImplicitParams with Swagger 2”

Enable email plugin for Logstash

Logstash comes with a bunch of plugins for input, filter and output processing pipelines. When monitoring logs using a platform like ELK the most requested feature is email notifications in case of sever error conditions or issues.  There are many options to enable sending emails using custom python scripts, Elastic watcher, elastalert, etc.

Continue reading “Enable email plugin for Logstash”

Spring Boot Essentials

As you have seen so far, Spring boot takes care of a lot of the boiler plate configurations required to setup a Spring application that we would have to do otherwise and helps us to get to the application coding part asap.

To do that, Spring boot has 4 tricks up its sleeve that it uses to accomplish what it does.

Continue reading “Spring Boot Essentials”

Spring Boot – Actuator setup

Spring Boot actuator provides useful metrics regarding your application like health, configurations, error pages, version information, etc. Setting up and using an Actuator in Spring Boot could not be easier than adding the correct dependency in the pom.xml file and using the appropriate url to access the metric information.

Continue reading “Spring Boot – Actuator setup”

Spring Boot – Using log4j logging

Spring boot uses an opinionated approach for a lot of things, with logging being one. It uses Logback by default. While Logback is useful, some of you may want to use a different log library. What do you have to do to use log4j as the logger?

Continue reading “Spring Boot – Using log4j logging”