I have seen lots of people who are doing code reviews and others who think it's just waste of time or they are not convinced about it. The latter are probably defensive and don't want for others to tell them how good or bad is their code. And most probably they don't write any kind… Continue reading Code review flavors
Category: Test your code
Testing microservices
Now the fun part. Assuming that we have built a running microservice environment, how can we maintain it? How do we introduce changes without breaking it? How do we test it? We know we can do end to end tests, but these are slow and we need faster feedback. How can we test the microservice… Continue reading Testing microservices
Mockito 2
As Junit 5 was released in order to be able to use mocks you need to add the mockito extension. You noticed that ClassRunners are deprecated now in Junit 5, they were replaced with extensions, hence the Mockito Extension. What changes are in Mockito 2? Well one of the most important one is the change… Continue reading Mockito 2
Build once vs build many
After we have written the code and compile it, the next step is to build and deploy it somewhere. We can go two ways here: build many times the code, deploy it many times build once the code, deploy it many times Build many This is the way many of you are familiar with, as… Continue reading Build once vs build many
Are you verifying your stubs?
What is stubbing? What is verifying? Do we need both? If we look into the java docs for Mockito.when() (stubbing) and Mockito.verify() (verifying behavior) we see something strange that is common to both: Although it is possible to verify a stubbed invocation, usually it's just redundant. Well, we known that the difference between stubs and… Continue reading Are you verifying your stubs?
Junit 5
What has changed? Is it still backwards compatible? Is it hard to migrate? These are some of the questions I want to answer with this post. Junit 5 is a bundle of 3 modules: platform, a platform for developing testing frameworks jupiter, the new programming model and extension model vintage, for running Junit 3 and… Continue reading Junit 5
Junit Theories
Theories are less known components of Junit, but lately I used them and thus decided to write about them. They come in handy when you have a situation when you need to test a behavior with multiple input values. Instead of writing tests for each situation you can specify a set of inputs and apply… Continue reading Junit Theories
Testing concurrent code
Let's get to some interesting stuff. How difficult is to test your concurrent code? The answer: very. Still there must be some ways of testing it, right? Well there are things that can help you. One of them is Thread Weaver. How does it work? Using byte-code instrumentation it will run your method that you… Continue reading Testing concurrent code
Mutation testing performance
In this post I wanna write about the mutation testing performance. If you want to refresh your memory on mutation testing you can check my previous post. We saw there that mutation testing takes lots of time to run and that we cannot run it every time. I've described there some ways to improve the… Continue reading Mutation testing performance
Power Mocks
Mockito is cool, but in some cases workarounds are required to resolve certain situations. These workarounds force you to alter your code is order to be testable, but for a person who reads the code may find some of it not that useful, until he is explained why it was done this way. I will describe some… Continue reading Power Mocks