Sunday, July 29th, 2018
When implementing distributed systems, client-server architectures and simple applications with network related functionalities, everything is fine when we’re in the development or in the testing stage because the network is reliable and the communicating systems are not as stressed as they are in production.
But to sleep well we want to validate how resilient we have implemented our systems, how they behave when the network fails, the latency rises, the bandwidth is limited, connections time out and so on.
In the following tutorial I will demonstrate how to set up a testing environment to simulate different classical network problems with a tool named Toxiproxy and I will show how to integrate it with the well known Java testing stack with Maven and JUnit.
(more…)
Tags: architecture, bandwidth, container, docker, docker-maven, downstream, failsafe, http, http-client, jigsaw, jitter, junit, latency, maven, module, network, resilient, surefire, testing, testrule, toxic, toxiproxy, toxiproxy-cli, upstream, wiremock
Posted in Java, testing | No Comments »
Wednesday, March 28th, 2018
When writing test for applications that interact with Kafka brokers we often need to setup a decent environment including an instance of Kafka and ZooKeeper.
Though Kafka ships with some classes for testing, setting up a simple testing environment is quite easier with the kafka-unit library that offers JUnit test rule support or a fast programmatic setup within no time.
In the following short example, I’d like to show how create a simple setup using Maven, Surefire and kafka-unit. (more…)
Tags: Apache, docker, integration-testing, it, junit, kafka, maven, surefire, tdd, testing, testrule, zookeeper
Posted in Java, testing | 1 Comment »
Monday, December 19th, 2016
When important data is written to STDIN/STDOUT and an application relies on specific system properties or environment variables, writing tests is getting more complicated.
System Rules is a collection of JUnit rules that helps us writing Java tests for everything that deals with java.lang.System.
In the following short examples I’d like to demonstrate how to deal with system properties, environment variables, STDOUT and STDERR and capturing both for testing e.g. for some golden master refactoring.
(more…)
Tags: environment, gradle, junit, maven, properties, system, system.in, system.out, tdd, testrule
Posted in Java, testing | No Comments »
Tuesday, February 21st, 2012
JUnit Rules are a handy solution if one needs to alter test methods or wants to share common functionality between several test cases. JUnit 4.10 introduced a new class to order several rules according to our needs using a so called rule-chain.
In the following example, we’re going to create a simple custom rule and afterwards bind several instances of it in a specified order to a test method.
(more…)
Tags: Api, classrule, externalresource, junit, rule, rulechain, tdd, testing, testrule
Posted in Java, testing | 7 Comments »