Home » Tag Archives: Testing (page 2)

Tag Archives: Testing

Boosting test performance with TestContainers


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 »

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 »

Importance of given-when-then in unit tests and TDD

Recently, I’ve been writing rather about more advanced concepts related to automatic testing (mostly related to Spock). However, conducting my testing training I clearly see that very often knowledge of particular tools is not the main problem. Even with Spock it is possible to write bloated and hard-to-maintain test, breaking (or not being aware of) good practices related to writing ...

Read More »

Automated Tests for Asynchronous Processes

It’s been a while since I’ve worked on a server-side application that had asynchronous behaviour that wasn’t already an event-driven system. Asynchronous behaviour is always an interesting challenge to design and test. In general, asynchronous behaviour should not be hard to unit test – after all, the behaviour of an action shouldn’t necessarily be coupled temporally (see forms of coupling). ...

Read More »

Every project is test driven in the end

Let me give you the punch-line and then explain myself: As soon as testing starts every “project” becomes a test driven. If there is no formal testing period then that phase begin the moment customers/users start using the product. I’ve recently been watching a slow motion train-crash, I had no power to avert the train crash and those I could ...

Read More »

Never trust a passing test

One of the lessons when practising TDD is to never trust a passing test. If you haven’t seen the test fail, are you sure it can fail? Red Green Refactor Getting used to the red-green-refactor cycle can be difficult. It’s very natural for a developer new to TDD to immediately jump into writing the production code. Even if you’ve written the ...

Read More »

Expected Exception Rule and Mocking Static Methods – JUnit

Today I was asked to consume a RESTful service so I started implementing it following Robert Cecil Martin’s rules for TDD and came across a new way (atleast for me) of testing the expected exception along with the error message so thought of sharing the way I implemented it as part of this post. To start with let’s write a ...

Read More »

Unit testing Java data classes immutability with the Mutability Detector

In all our project, we use data classes which, by definition, contain data (fields) but no (business) logic. According to the best coding practices, a data class should preferably be immutable because immutability means thread safety. Main reference here is Joshua Bloch’s Effective Java book; this Yegor Bugayenko’s post is also very interesting reading. An immutable class has several interesting ...

Read More »

[MEGA DEAL] The Ultimate Software Testing Bundle (98%)

In 84 Hours, You’ll Have the Skills You Need to Be A Software Tester In High Demand Hey fellow geeks, This week, on our JCG Deals store, we have an extreme offer. We are offering The Ultimate Software Testing Bundle for only $59 instead of the original price of $3,690, yeap that is a massive 98% off. Software Products Need ...

Read More »