<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Testrule on Micha Kops&#39; Tech Notes</title>
    <link>https://www.hascode.com/tags/testrule/</link>
    <description>Recent content in Testrule on Micha Kops&#39; Tech Notes</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright © 2010 - 2025 Micha Kops. #e9d956c0c0154a221ad83c925346a8fa0e72f866</copyright>
    <lastBuildDate>Sun, 29 Jul 2018 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://www.hascode.com/tags/testrule/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Testing Java Applications for Resilience by Simulating Network Problems with Toxiproxy, JUnit and the Docker Maven Plugin</title>
      <link>https://www.hascode.com/testing-java-applications-for-resilience-by-simulating-network-problems-with-toxiproxy-junit-and-the-docker-maven-plugin/</link>
      <pubDate>Sun, 29 Jul 2018 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/testing-java-applications-for-resilience-by-simulating-network-problems-with-toxiproxy-junit-and-the-docker-maven-plugin/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Setting up Kafka Brokers for Testing with Kafka-Unit</title>
      <link>https://www.hascode.com/setting-up-kafka-brokers-for-testing-with-kafka-unit/</link>
      <pubDate>Wed, 28 Mar 2018 00:00:00 +0200</pubDate>
      <guid>https://www.hascode.com/setting-up-kafka-brokers-for-testing-with-kafka-unit/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;In the following short example, I’d like to show how create a simple setup using Maven, Surefire and kafka-unit.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Handling System Properties, Environment Variables, STDOUT/STDERR in JUnit Tests with System Rules</title>
      <link>https://www.hascode.com/handling-system-properties-environment-variables-stdout/stderr-in-junit-tests-with-system-rules/</link>
      <pubDate>Mon, 19 Dec 2016 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/handling-system-properties-environment-variables-stdout/stderr-in-junit-tests-with-system-rules/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;System Rules is a collection of JUnit rules that helps us writing Java tests for everything that deals with java.lang.System.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
    <item>
      <title>Ordering your JUnit Rules using a RuleChain</title>
      <link>https://www.hascode.com/ordering-your-junit-rules-using-a-rulechain/</link>
      <pubDate>Tue, 21 Feb 2012 00:00:00 +0100</pubDate>
      <guid>https://www.hascode.com/ordering-your-junit-rules-using-a-rulechain/</guid>
      <description>&lt;div id=&#34;preamble&#34;&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;sect1&#34;&gt;
&lt;h2 id=&#34;_adding_junit&#34;&gt;Adding JUnit&lt;/h2&gt;
&lt;div class=&#34;sectionbody&#34;&gt;
&lt;div class=&#34;paragraph&#34;&gt;
&lt;p&gt;Just one Maven dependency needed here – JUnit 4.10&lt;/p&gt;
&lt;/div&gt;</description>
    </item>
  </channel>
</rss>
