mm
Kostis Kapelonis

Kostis is a Software Engineer who loves clean and compact code, simple solutions and modular distributed systems. He hates feature creep, over-engineering, XML gluttony and monolithic systems. He has a soft spot for code Quality and build systems.

Posts by: Kostis Kapelonis

Stubbing and Mocking in Java with the Spock Testing Framework

Introduction When it comes to true unit tests, having a mocking framework such as Spock for Java is essential. Using a mocking framework ensures that your unit tests are fast, self-contained and deterministic. A mocking framework can help you fake external systems, pre-program your classes with expected responses, and test hard-to-replicate error conditions. There are several mocking frameworks in the Java world, but the most popular one is Mockito. Our…

Stubbing and Mocking with Mockito 2 and JUnit

Introduction Mocking and stubbing are the cornerstones of having quick and simple unit tests. Mocks are useful if you have a dependency on an external system, file reading takes too long, database connection is unreliable, or if you don’t want to send an email after every test. Unlike with integration or functional tests, where the real system is being tested as a whole, unit tests should focus on a single…

Testing REST Endpoints Using REST Assured

Introduction Having a large collection of unit tests that verify the behaviour of Java classes is only the first step to a sound testing strategy. After all, the fact that individual Java classes work successfully in isolation does not mean that the application itself will also work correctly ,when all these classes are bundled together. In addition to basic unit tests, we also need integration tests (tests that focus on…

How to Split JUnit Tests in a Continuous Integration Environment

Introduction Continuous Integration/Delivery has gained widespread acceptance in the minds of developers, and has become an important aspect of the quick release cycles in the software industry. However, adopting continuous integration is not going to bring any benefits, if we don’t make sure that our build system can run in a CI environment with multiple stages (i.e. pipeline). A highly granular build process requires the split of unit tests according…