<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>TestContainers - Tag - Nuno Sousa&#39;s Corner</title>
        <link>https://www.nunomtsousa.com/tags/testcontainers/</link>
        <description>TestContainers - Tag - Nuno Sousa&#39;s Corner</description>
        <generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>nuno.mt.sousa@gmail.com (Nuno Sousa)</managingEditor>
            <webMaster>nuno.mt.sousa@gmail.com (Nuno Sousa)</webMaster><lastBuildDate>Sun, 26 Nov 2023 18:23:34 &#43;0000</lastBuildDate><atom:link href="https://www.nunomtsousa.com/tags/testcontainers/" rel="self" type="application/rss+xml" /><item>
    <title>Kafka, Schema Registry, JUnit and Test Containers — Part III: Reducing test time by removing all topics between tests</title>
    <link>https://www.nunomtsousa.com/posts/2023-11-26-kafacontainerspart3/</link>
    <pubDate>Sun, 26 Nov 2023 18:23:34 &#43;0000</pubDate>
    <author>nuno.mt.sousa@gmail.com (Nuno Sousa)</author>
    <guid>https://www.nunomtsousa.com/posts/2023-11-26-kafacontainerspart3/</guid>
    <description><![CDATA[<h2 id="introduction">Introduction</h2>
<p>In <a href="https://www.nunomtsousa.com/posts/2023-11-16-kafacontainerspart2/" rel="">Part II</a> of this series, we saw how we could create a JUnit Test Extension to make testing with test containers easier. We just need to add the extension to the test to leverage both containers. In fact, we can even add more utility methods to the KafkTestCluster utility class for things we need. The problem is that each time we have a test that uses this extension, we pay more than 20 seconds for the start-up time of both Kafka and the Schema registry. How can we improve this solution?</p>]]></description>
</item>
<item>
    <title>Kafka, Schema Registry, JUnit and Test Containers — Part II: Creating a Kafka Cluster Test Extension</title>
    <link>https://www.nunomtsousa.com/posts/2023-11-16-kafacontainerspart2/</link>
    <pubDate>Thu, 16 Nov 2023 18:20:33 &#43;0000</pubDate>
    <author>nuno.mt.sousa@gmail.com (Nuno Sousa)</author>
    <guid>https://www.nunomtsousa.com/posts/2023-11-16-kafacontainerspart2/</guid>
    <description><![CDATA[<h2 id="introduction">Introduction</h2>
<p>In <a href="https://www.nunomtsousa.com/posts/2023-11-13-kafacontainerspart1/" rel="">Part I</a>of this series, we saw how we could leverage <a href="https://testcontainers.com/" target="_blank" rel="noopener noreffer ">Test Containers</a> to make integration tests that require a <a href="https://kafka.apache.org/" target="_blank" rel="noopener noreffer ">Kafka</a> Cluster and a Schema Registry, although we used a single-node Kafka Cluster. In this part, we will refactor the code so that it can be easily used in multiple tests.</p>
<h2 id="creating-a-junit5-extension">Creating a JUnit5 Extension</h2>
<p>To reuse code, we will create a <a href="https://junit.org/junit5/docs/current/user-guide/#extensions" target="_blank" rel="noopener noreffer ">JUnit5 Extension</a>. Usually we use these extensions, but creating one is quite simple and opens a new door for test code reuse. As a side note, what is being done here can also be done in JUnit4, but for JUnit4 you are probably better off developing a <a href="https://junit.org/junit4/javadoc/4.12/org/junit/rules/TestRule.html" target="_blank" rel="noopener noreffer ">Test Rule</a>.</p>]]></description>
</item>
<item>
    <title>Kafka, Schema Registry, JUnit and Test Containers — Part I</title>
    <link>https://www.nunomtsousa.com/posts/2023-11-13-kafacontainerspart1/</link>
    <pubDate>Mon, 13 Nov 2023 18:14:24 &#43;0000</pubDate>
    <author>nuno.mt.sousa@gmail.com (Nuno Sousa)</author>
    <guid>https://www.nunomtsousa.com/posts/2023-11-13-kafacontainerspart1/</guid>
    <description><![CDATA[<h2 id="introduction">Introduction</h2>
<p>In this small series of articles, I will share some ideas on using <a href="https://junit.org/" target="_blank" rel="noopener noreffer ">JUnit</a> and <a href="https://testcontainers.com/" target="_blank" rel="noopener noreffer ">Test Containers</a> to test a <a href="https://kafka.apache.org/" target="_blank" rel="noopener noreffer ">Kafka</a> application. The use of test containers fits more into the integration test category than the unit test one, but I am not going to dive into that discussion. For me, tests help me develop software faster, be more focused and get faster feedback to know if I am going in the right direction or not. As a side note, yes, I believe and practice in Test Driven Development, but even if you write your tests after, I hope the ideas shared in this and the following articles are useful to you too.</p>]]></description>
</item>
</channel>
</rss>
