<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rafiullah Hamedy</title>
    <description>The latest articles on DEV Community by Rafiullah Hamedy (@rhamedy).</description>
    <link>https://dev.to/rhamedy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F202225%2F537a8230-7d9b-42ba-9508-8d8a2fda1b69.png</url>
      <title>DEV Community: Rafiullah Hamedy</title>
      <link>https://dev.to/rhamedy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rhamedy"/>
    <language>en</language>
    <item>
      <title>JUnit 4 &amp; 5 Annotations Every Developer Should Know</title>
      <dc:creator>Rafiullah Hamedy</dc:creator>
      <pubDate>Tue, 05 Nov 2019 14:51:29 +0000</pubDate>
      <link>https://dev.to/rhamedy/junit-4-5-annotations-every-developer-should-know-5f6c</link>
      <guid>https://dev.to/rhamedy/junit-4-5-annotations-every-developer-should-know-5f6c</guid>
      <description>&lt;h1&gt;
  
  
  A Summary of JUnit 4 &amp;amp; 5 Annotations with Examples
&lt;/h1&gt;

&lt;p&gt;Before writing this article, I only knew a few commonly used JUnit 4 annotations such as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RunWith 
@Test
@Before
@After
@BeforeClass
@AfterClass
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;How many times did you have to comment out a test? To my surprise, there are annotations to do just that.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Ignore("Reason for ignoring")
@Disabled("Reason for disabling")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Well, it turns out that there are a handful of other annotations, especially in JUnit 5 that could help write better and more efficient tests.&lt;/p&gt;


&lt;h2&gt;
  
  
  What to expect?
&lt;/h2&gt;

&lt;p&gt;In this article, I will cover the following annotations with usage examples. The purpose of this article is to introduce you to the annotation, it will not go into greater details of each annotation.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;All the examples from this article are also available in the Github. Please checkout the following repository. *&lt;/em&gt;&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/rhamedy"&gt;
        rhamedy
      &lt;/a&gt; / &lt;a href="https://github.com/rhamedy/junit-annotations-examples"&gt;
        junit-annotations-examples
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      JUnit 4 and 5 Annotations with Examples
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;The target audience of this article is developers of any level.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pEBw2UxZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lutifty7vsbuxrz4nqwu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pEBw2UxZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lutifty7vsbuxrz4nqwu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  JUnit 4
&lt;/h3&gt;

&lt;p&gt;The following &lt;a href="https://github.com/junit-team/junit4"&gt;JUnit 4&lt;/a&gt; annotations will be covered&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MMIdq81B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/4cp8t1zggjoyt4p6r7yv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MMIdq81B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/4cp8t1zggjoyt4p6r7yv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  JUnit 5
&lt;/h3&gt;

&lt;p&gt;The following &lt;a href="https://github.com/junit-team/junit5"&gt;JUnit 5&lt;/a&gt; annotations are explained with examples&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_VuFZ0cJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/53m3mi7b0ds4gzld9lik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_VuFZ0cJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/53m3mi7b0ds4gzld9lik.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  JUnit Dependencies
&lt;/h2&gt;

&lt;p&gt;All the examples in this article are tested using the following JUnit dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'&lt;/span&gt;
&lt;span class="s"&gt;testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'&lt;/span&gt;
&lt;span class="s"&gt;testCompileOnly 'junit:junit:4.12'&lt;/span&gt;
&lt;span class="s"&gt;testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Please check out the Github &lt;a href="https://github.com/rhamedy/junit-annotations-examples"&gt;repository&lt;/a&gt; for more details.&lt;/p&gt;


&lt;h1&gt;
  
  
  JUnit Annotations Usage
&lt;/h1&gt;

&lt;p&gt;Let's explore the JUnit 4 annotations one by one with a brief usage example&lt;/p&gt;
&lt;h2&gt;
  
  
  The Hello World of Unit Testing
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@Test&lt;/code&gt; annotation is used to mark a method as a test.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BasicJUnit4Tests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;always_passing_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Always true"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The Class-Level and Test-Level Annotations
&lt;/h2&gt;

&lt;p&gt;Annotations such as &lt;code&gt;@BeforeClass&lt;/code&gt; and &lt;code&gt;@AfterClass&lt;/code&gt; are &lt;strong&gt;JUnit 4&lt;/strong&gt; class-level annotations.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BasicJUnit4Tests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@BeforeClass&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Setup resource needed by all tests.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Before&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;beforeEveryTest&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// This gets executed before each test.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;always_passing_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Always true"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@After&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;afterEveryTest&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// This gets executed after every test.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@AfterClass&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;cleanup&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Clean up resource after all are executed.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The annotations &lt;code&gt;@BeforeAll&lt;/code&gt; and &lt;code&gt;@AfterAll&lt;/code&gt; are &lt;strong&gt;JUnit 5&lt;/strong&gt; equivalents and imported using the following statements.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// JUnit 5&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.jupiter.api.BeforeAll&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.jupiter.api.AfterAll&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Ignoring a Test vs. Assumption
&lt;/h2&gt;

&lt;p&gt;A test is ignored with &lt;code&gt;@Ignore&lt;/code&gt; annotation or an assertion can be changed to an assumption and JUnit Runner will ignore a failing assumption.&lt;/p&gt;

&lt;p&gt;Assumptions are used when dealing with scenarios such as server vs. local timezone. When an assumption fails, an &lt;code&gt;AssumptionViolationException&lt;/code&gt; is thrown, and JUnit runner will ignore it.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BasicJUnit4Tests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Ignore&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Ignored because of a good reason"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_something&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Always fails"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Executing Tests in Order
&lt;/h2&gt;

&lt;p&gt;Generally, it is a good practice to write order agnostic unit tests.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@FixMethodOrder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;MethodSorters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;NAME_ASCENDING&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FixedMethodOrderingTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;second&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;third&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In addition to sorting in ascending order of test names, the &lt;code&gt;MethodSorter&lt;/code&gt; allow &lt;code&gt;DEFAULT&lt;/code&gt; and &lt;code&gt;JVM&lt;/code&gt; level sorting.&lt;/p&gt;


&lt;h2&gt;
  
  
  Adding Timeout to Tests
&lt;/h2&gt;

&lt;p&gt;Unit tests would mostly have fast execution time; however, there might be cases when a unit test would take a longer time.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;JUnit 4&lt;/strong&gt;, the &lt;code&gt;@Test&lt;/code&gt; annotation accepts &lt;code&gt;timeout&lt;/code&gt; argument as shown below&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.Ignore&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.Test&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BasicJUnit4Tests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;timeout_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;InterruptedException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sleep&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Fails because it took longer than 1 second.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In &lt;strong&gt;JUnit 5&lt;/strong&gt;, the timeout happens at the assertion level&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;static&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Duration&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ofMillis&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;static&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;junit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;jupiter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Assertions&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;assertTimeout&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.jupiter.api.Test&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BasicJUnit5Tests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_timeout&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Test takes 2 ms, assertion timeout in 1 ms&lt;/span&gt;
    &lt;span class="n"&gt;assertTimeout&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ofMillis&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sleep&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;});&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Sometimes it is more meaningful to apply a timeout across all tests which includes the &lt;code&gt;@BeforeEach/Before&lt;/code&gt; and &lt;code&gt;@AfterEach/After&lt;/code&gt; as well.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnitGlobalTimeoutRuleTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Rule&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Timeout&lt;/span&gt; &lt;span class="n"&gt;globalTimeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Timeout&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;TimeUnit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;SECONDS&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;timeout_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;InterruptedException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Infinite loop&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;timeout_test_pass&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;InterruptedException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sleep&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Using Rule with JUnit Tests
&lt;/h2&gt;

&lt;p&gt;I find &lt;code&gt;@Rule&lt;/code&gt; very helpful when writing unit tests. A &lt;strong&gt;Rule&lt;/strong&gt; is applied to the following&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Timeout - showcased above&lt;/li&gt;
&lt;li&gt;ExpectedException&lt;/li&gt;
&lt;li&gt;TemporaryFolder&lt;/li&gt;
&lt;li&gt;ErrorCollector&lt;/li&gt;
&lt;li&gt;Verifier&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  ExpectedException Rule
&lt;/h3&gt;

&lt;p&gt;This rule can be used to ensure that a test throws an expected exception. In &lt;strong&gt;JUnit 4&lt;/strong&gt;, we can do something as follow&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BasicJUnit4Tests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expected&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NullPointerException&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;exception_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;IllegalArgumentException&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Fail. Not NPE.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In &lt;strong&gt;JUnit 5&lt;/strong&gt;, however, the above can be achieved via an assertion as follow&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BasicJUnit5Tests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_expected_exception&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Assertions&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;assertThrows&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;NumberFormatException&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;parseInt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"One"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Throws NumberFormatException&lt;/span&gt;
    &lt;span class="o"&gt;});&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;We can also define a &lt;strong&gt;Rule&lt;/strong&gt; in the class-level and reuse it in the tests&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnitRuleTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Rule&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ExpectedException&lt;/span&gt; &lt;span class="n"&gt;thrown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ExpectedException&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;none&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;expectedException_inMethodLevel&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;thrown&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;expect&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IllegalArgumentException&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;thrown&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;expectMessage&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Cause of the error"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;IllegalArgumentException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Cause of the error"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  TemporaryFolder Rule
&lt;/h3&gt;

&lt;p&gt;This &lt;strong&gt;Rule&lt;/strong&gt; facilities the creation and deletion of a file and folder during the lifecycle of a test.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TemporaryFolderRuleTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Rule&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;TemporaryFolder&lt;/span&gt; &lt;span class="n"&gt;temporaryFolder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TemporaryFolder&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testCreatingTemporaryFileFolder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;IOException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;temporaryFolder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newFile&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"testFile.txt"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="n"&gt;folder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;temporaryFolder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newFolder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"testFolder"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;filePath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAbsolutePath&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;folderPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;folder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAbsolutePath&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="n"&gt;testFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filePath&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;File&lt;/span&gt; &lt;span class="n"&gt;testFolder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;File&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;folderPath&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;testFile&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;exists&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;testFolder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;exists&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;testFolder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isDirectory&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
 &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  ErrorCollector Rule
&lt;/h3&gt;

&lt;p&gt;During the execution of a unit test, if there are many assertions and the first one fails then subsequent declarations are skipped as shown below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Test&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;reportFirstFailedAssertion&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Failed assertion. Report. Stop execution.&lt;/span&gt;
  &lt;span class="n"&gt;assertFalse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// It's never executed.&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;It would be helpful if we could get a list of all failed assertions and fix them at once instead of one by one. Here is how the &lt;strong&gt;ErrorCollector&lt;/strong&gt; Rule can help achieve that.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ErrorCollectorRuleTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Rule&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ErrorCollector&lt;/span&gt; &lt;span class="n"&gt;errorCollector&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ErrorCollector&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;reportAllFailedAssertions&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;errorCollector&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;checkThat&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;  &lt;span class="c1"&gt;// Fail. Continue&lt;/span&gt;
    &lt;span class="n"&gt;errorCollector&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;checkThat&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Pass. Continue&lt;/span&gt;
    &lt;span class="n"&gt;errorCollector&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;checkThat&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;equalTo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"a"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;  &lt;span class="c1"&gt;// Fail. Report all&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;There is also the &lt;strong&gt;Verifier&lt;/strong&gt; Rule that I won't go into details, and you can read more about it &lt;a href="https://junit.org/junit4/javadoc/4.12/org/junit/rules/Verifier.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For more information on &lt;code&gt;@ClassRule&lt;/code&gt; and the difference between the two, please see this &lt;a href="https://stackoverflow.com/questions/41121778/junit-rule-and-classrule/41122264"&gt;Stackoverflow&lt;/a&gt; post.&lt;/p&gt;


&lt;h2&gt;
  
  
  JUnit Suites
&lt;/h2&gt;

&lt;p&gt;The JUnit Suites can be used to group test classes and execute them together. Here is an example&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TestSuiteA&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testSuiteA&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TestSuiteB&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testSuiteB&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Assuming that there are many other test classes, we could run both or one of these using the following annotations&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RunWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Suite&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Suite&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;SuiteClasses&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="nc"&gt;TestSuiteA&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;TestSuiteB&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TestSuite&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Will run tests from TestSuiteA and TestSuiteB classes&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The above would result in the following&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KXs4awOb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/teff8b64tqfvj64nb1tj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KXs4awOb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/teff8b64tqfvj64nb1tj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Categories in JUnit 4
&lt;/h2&gt;

&lt;p&gt;In &lt;strong&gt;JUnit 4&lt;/strong&gt;, we can make use of the &lt;strong&gt;Categories&lt;/strong&gt; to include and exclude a group of tests from execution. We can create as many categories as we want using a marker interface as shown below&lt;/p&gt;

&lt;p&gt;&lt;em&gt;An interface with no implementation is called a marker interface.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;CategoryA&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;CategoryB&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Now that we have two categories, we can annotate each test with one or more category types as shown below&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CategoriesTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_categoryNone&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Test without any category"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Category&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CategoryA&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test1&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Runs when category A is selected."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Category&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CategoryB&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test2&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Runs when category B is included."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Category&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="nc"&gt;CategoryA&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CategoryB&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test3&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Runs when either of category is included."&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;A special JUnit Runner called &lt;code&gt;Categories.class&lt;/code&gt; is used to execute these tests&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RunWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Categories&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@IncludeCategory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CategoryA&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@ExcludeCategory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CategoryB&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@SuiteClasses&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="nc"&gt;CategoriesTests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CategroyTestSuite&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The above would only run test &lt;code&gt;test1&lt;/code&gt; , however, if we remove the following entry then both &lt;code&gt;test1&lt;/code&gt; and &lt;code&gt;test3&lt;/code&gt; are executed.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@ExcludeCategory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CategoryB&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Tagging &amp;amp; Filtering Tests in JUnit 5
&lt;/h2&gt;

&lt;p&gt;In addition to the Categories in &lt;strong&gt;JUnit 4&lt;/strong&gt;, &lt;strong&gt;JUnit 5&lt;/strong&gt; introduces the ability to tag and filter tests. Let's assume we have the following&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"development"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UnitTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"web-layer"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;login_controller_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"web-layer"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;logout_controller_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"db-layer"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"dao"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;user_dao_tests&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"qa"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LoadTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"auth"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;login_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"auth"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;logout_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"auth"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;forgot_password_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
  &lt;span class="nd"&gt;@Tag&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"report"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;generate_monthly_report&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;As shown above, tags apply to both the entire class as well as individual methods. Let's execute all the tests tagged as &lt;code&gt;qa&lt;/code&gt; in a given package.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RunWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;JUnitPlatform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@SelectPackages&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"junit.exmaples.v2.tags"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@IncludeTags&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"qa"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit5TagTests&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The above would result in the following output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ja5bewub--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ic7k31c2phuedgybahuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ja5bewub--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ic7k31c2phuedgybahuh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown above, only the test class with &lt;code&gt;qa&lt;/code&gt; tag is run. Let's run both &lt;code&gt;qa&lt;/code&gt; and &lt;code&gt;development&lt;/code&gt; tagged tests but, filter the &lt;code&gt;dao&lt;/code&gt; and &lt;code&gt;report&lt;/code&gt; tagged tests.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RunWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;JUnitPlatform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@SelectPackages&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"junit.exmaples.v2.tags"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@IncludeTags&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="s"&gt;"qa"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"development"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="nd"&gt;@ExcludeTags&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="s"&gt;"report"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"dao"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit5TagTests&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;As shown below, the two tests annotated with &lt;code&gt;dao&lt;/code&gt; and &lt;code&gt;report&lt;/code&gt; are excluded.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1TghAeg_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gr3fdig6ikpcy1fsukca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1TghAeg_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gr3fdig6ikpcy1fsukca.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Parametrizing Unit Tests
&lt;/h2&gt;

&lt;p&gt;JUnit allows parametrizing a test to be executed with different arguments instead of copy/pasting the test multiple times with different arguments or building custom utility methods.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RunWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Parameterized&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit4ParametrizedAnnotationTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Parameter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nd"&gt;@Parameter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;expectedResult&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// Must be static and return collection.&lt;/span&gt;
  &lt;span class="nd"&gt;@Parameters&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{0} is a Prime? {1}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;[]&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;testData&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Arrays&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;asList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;[][]&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;},&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;},&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;},&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;});&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_isPrime&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;PrimeNumberUtil&lt;/span&gt; &lt;span class="n"&gt;util&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PrimeNumberUtil&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;assertSame&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;util&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isPrime&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="n"&gt;expectedResult&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;To parametrize the &lt;code&gt;test_isPrime&lt;/code&gt; test we need the following&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make use of the specialized &lt;code&gt;Parametrized.class&lt;/code&gt; JUnit Runner&lt;/li&gt;
&lt;li&gt;Declare a non-private static method that returns a Collection annotated with &lt;code&gt;@Parameters&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Declare each parameter with &lt;code&gt;@Parameter&lt;/code&gt;  and value attribute&lt;/li&gt;
&lt;li&gt;Make use of the &lt;code&gt;@Parameter&lt;/code&gt; annotated fields in the test&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is how the output of our parameterized &lt;code&gt;test_isPrime&lt;/code&gt; look like&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XaV62P7z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dzum7w3u2n4juqdie187.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XaV62P7z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dzum7w3u2n4juqdie187.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above is a using &lt;code&gt;@Parameter&lt;/code&gt; injection, and we can also achieve the same result using a constructor, as shown below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit4ConstructorParametrized&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;expectedResult&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;JUnit4ConstructorParametrized&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;expectedResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In JUnit 5, the &lt;code&gt;@ParameterizedTest&lt;/code&gt; is introduced with the following sources&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;@ValueSource&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;@EnumSource&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;@MethodSource&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;@CsvSource&lt;/code&gt; and &lt;code&gt;@CsvFileSource&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's explore each of them in detail.&lt;/p&gt;


&lt;h2&gt;
  
  
  Parameterized Tests with a ValueSource
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@ValueSource&lt;/code&gt; annotation allows the following declarations&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@ValueSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Hi"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"How"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Are"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"You?"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="nd"&gt;@ValueSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ints&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="nd"&gt;@ValueSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;longs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1L&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2L&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3L&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="nd"&gt;@ValueSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doubles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.3&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Let's use one of the above in a test&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@ParameterizedTest&lt;/span&gt;
&lt;span class="nd"&gt;@ValueSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Hi"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"How"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Are"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"You?"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testStrings&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;arg&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Parameterized Tests with an EnumSource
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@EnumSource&lt;/code&gt; annotation could be used in the following ways&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@EnumSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@EnumSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="s"&gt;"MEDIUM"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"HIGH"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="nd"&gt;@EnumSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Mode&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;INCLUDE&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="s"&gt;"MEDIUM"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"HIGH"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Similar to &lt;code&gt;ValueSource&lt;/code&gt;, we can use &lt;code&gt;EnumSource&lt;/code&gt; in the following way&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@ParameterizedTest&lt;/span&gt;
&lt;span class="nd"&gt;@EnumSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Mode&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;EXCLUDE&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="s"&gt;"MEDIUM"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"HIGH"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testEnums_exclude_Specific&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Level&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;EnumSet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;MEDIUM&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Level&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;HIGH&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Parameterized Tests with a MethodSource
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;@MethodSource&lt;/code&gt; annotation accepts a method name that is providing the input data. The method that provides input data could return a single parameter, or we could make use of &lt;code&gt;Arguments&lt;/code&gt; as shown below&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit5MethodArgumentParametrizedTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@ParameterizedTest&lt;/span&gt;
  &lt;span class="nd"&gt;@MethodSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"someIntegers"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_MethodSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;someIntegers&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Arrays&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;asList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The following is an example of &lt;code&gt;Arguments&lt;/code&gt; and it can also be used to return a POJO&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit5MethodArgumentParametrizedTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@ParameterizedTest&lt;/span&gt;
  &lt;span class="nd"&gt;@MethodSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"argumentsSource"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_MethodSource_withMoreArgs&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;switch&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Jan"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Feb"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Mar"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;assertFalse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Arguments&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;argumentsSource&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Arrays&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;asList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="nc"&gt;Arguments&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Jan"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nc"&gt;Arguments&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Feb"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nc"&gt;Arguments&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Mar"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="nc"&gt;Arguments&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Apr"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Fail.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Parameterized Tests with a CSV Sources
&lt;/h2&gt;

&lt;p&gt;When it comes to executing a test with a CSV content, the &lt;strong&gt;JUnit 5&lt;/strong&gt; provides two different types of sources for the &lt;strong&gt;ParametrizedTest&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;CsvSource&lt;/code&gt; - comma-separated values&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;CsvFileSource&lt;/code&gt; - reference to a CSV file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of a &lt;code&gt;CsvSource&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@ParameterizedTest&lt;/span&gt;
&lt;span class="nd"&gt;@CsvSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delimiter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sc"&gt;','&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"1,'A'"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"2,'B'"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_CSVSource_commaDelimited&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Arrays&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;asList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"A"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"B"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Assuming that we have the following entries in &lt;code&gt;sample.csv&lt;/code&gt; file under &lt;code&gt;src/test/resources&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name, Age
Josh, 22
James, 19
Jonas, 55
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;CsvFileSource&lt;/code&gt; case would look as follow&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@ParameterizedTest&lt;/span&gt;
&lt;span class="nd"&gt;@CsvFileSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"/sample.csv"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numLinesToSkip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;delimiter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;','&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_CSVFileSource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Arrays&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;asList&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"James"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Josh"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Resulting in 2 successful test runs and one failure because of the last entry in &lt;code&gt;sample.csv&lt;/code&gt; that fails the assertion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ca_IWBFE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/x0p3khw2fmfspkj8gfqn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ca_IWBFE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/x0p3khw2fmfspkj8gfqn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also design custom converters that would transform a CSV into an object. See &lt;a href="https://github.com/CodeFX-org/demo-junit-5/blob/master/src/test/java/org/codefx/demo/junit5/parameterized/CustomArgumentConverterTest.java"&gt;here&lt;/a&gt; for more details.&lt;/p&gt;


&lt;h2&gt;
  
  
  Theory in JUnit4
&lt;/h2&gt;

&lt;p&gt;The annotation &lt;code&gt;@Theory&lt;/code&gt; and the Runner &lt;strong&gt;Theories&lt;/strong&gt; are experimental features. In comparison with &lt;strong&gt;Parametrized&lt;/strong&gt; Tests, a &lt;strong&gt;Theory&lt;/strong&gt; feeds all combinations of the data points to a test, as shown below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RunWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Theories&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit4TheoriesTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@DataPoint&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Java"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nd"&gt;@DataPoint&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"node"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nd"&gt;@Theory&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_theory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Theory&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_theory_combos&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" - "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;When the above test class is executed, the &lt;code&gt;test_theory&lt;/code&gt; test will output 2¹ combination&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Java
node
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;However, the test &lt;code&gt;test_theory_combos&lt;/code&gt; would output all the combinations of the two data points. In other words, 2² combinations.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Java - Java
Java - node
node - Java
node - node
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If we have the following data point &lt;code&gt;oss&lt;/code&gt; then &lt;code&gt;test_theory_one&lt;/code&gt; test would generate 2³ combinations (2 number of args ^ 3 data points). The test &lt;code&gt;test_theory_two&lt;/code&gt; would create 3³ combinations.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@DataPoints&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;oss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Linux"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"macOS"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Windows"&lt;/span&gt;&lt;span class="o"&gt;};&lt;/span&gt;
&lt;span class="nd"&gt;@Theory&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_theory_one&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" - "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nd"&gt;@Theory&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_theory_two&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" &amp;lt;-&amp;gt; "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;-&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The following is a valid data point&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@DataPoints&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="nf"&gt;numbers&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;};&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  JUnit 5 Test DisplayName
&lt;/h2&gt;

&lt;p&gt;JUnit 5 has introduced &lt;code&gt;@DisplayName&lt;/code&gt; annotation that is used to give an individual test or test class a display name, as shown below.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Test&lt;/span&gt;
&lt;span class="nd"&gt;@DisplayName&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Test If Given Number is Prime"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;is_prime_number_test&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and it would show as follow in the console&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N-1ufJPD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tz2lf5h94q8hr1lu67y9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N-1ufJPD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tz2lf5h94q8hr1lu67y9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Repeating a JUnit Test
&lt;/h2&gt;

&lt;p&gt;Should the need arise to repeat a unit test X number of times, &lt;strong&gt;JUnit 5&lt;/strong&gt; provides &lt;code&gt;@RepeatedTest&lt;/code&gt; annotation.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RepeatedTest&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_executed_twice&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"RepeatedTest"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Prints twice&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;@RepeatedTest&lt;/code&gt; comes along with &lt;code&gt;currentReptition&lt;/code&gt;, &lt;code&gt;totalRepetition&lt;/code&gt; variables as well as &lt;code&gt;TestInfo.java&lt;/code&gt; and &lt;code&gt;RepetitionInfo.java&lt;/code&gt; Objects.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RepeatedTest&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{displayName} executed {currentRepetition} of {totalRepetitions}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@DisplayName&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Repeated 3 Times Test"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;repeated_three_times&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;TestInfo&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"display name matches"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; 
     &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getDisplayName&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Repeated 3 Times Test"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;We could also use the &lt;code&gt;RepetitionInfo.java&lt;/code&gt; to find out the current and total number of repetitions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QKxatJue--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/h0u0ttdbaecb49ljg2ho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QKxatJue--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/h0u0ttdbaecb49ljg2ho.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Executing Inner Class Unit Tests using JUnit 5's Nested
&lt;/h2&gt;

&lt;p&gt;I was surprised to learn that JUnit Runner does not scan inner classes for tests.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit5NestedAnnotationTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_outer_class&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit5NestedAnnotationTestsNested&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Test&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_inner_class&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;assertFalse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Never executed.&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;When Running the above test class, it will only execute the &lt;code&gt;test_outer_class&lt;/code&gt; and report &lt;strong&gt;success&lt;/strong&gt;, however, when marking the inner class with &lt;code&gt;@Nested&lt;/code&gt; annotation, both tests are run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--heZkb24L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uzpzm8j2y3mo1kqfpluk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--heZkb24L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uzpzm8j2y3mo1kqfpluk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  JUnit 5 Test Lifecycle with TestInstance Annotation
&lt;/h2&gt;

&lt;p&gt;Before invoking each &lt;code&gt;@Test&lt;/code&gt; method, JUnit Runner creates a new instance of the class. This behavior can be changed with the help of &lt;code&gt;@TestInstance&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@TestInstance&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;LifeCycle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PER_CLASS&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@TestInstance&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;LifeCycle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PER_METHOD&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;For more information on &lt;code&gt;@TestInstance(LifeCycle.PER_CLASS)&lt;/code&gt; please check out the &lt;a href="https://junit.org/junit5/docs/5.0.1/api/org/junit/jupiter/api/TestInstance.html"&gt;documentation&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  DynamicTests using JUnit 5 TestFactory Annotation
&lt;/h2&gt;

&lt;p&gt;JUnit tests annotated with &lt;code&gt;@Test&lt;/code&gt; are static tests because they are specified in compile-time. On the other hand, &lt;code&gt;DynamicTests&lt;/code&gt; are generated during runtime. Here is an example of &lt;code&gt;DynamicTests&lt;/code&gt; using the &lt;code&gt;PrimeNumberUtil&lt;/code&gt; class.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Junit5DynamicTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@TestFactory&lt;/span&gt;
  &lt;span class="nc"&gt;Stream&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DynamicTest&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;dynamicTests&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;PrimeNumberUtil&lt;/span&gt; &lt;span class="n"&gt;util&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PrimeNumberUtil&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;IntStream&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
       &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;mapToObj&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;DynamicTest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dynamicTest&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Is "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" Prime?"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;util&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isPrime&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;))));&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;For more on dynamic tests, see this &lt;a href="https://blog.codefx.org/libraries/junit-5-dynamic-tests/"&gt;blog post&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  Conditionally Executing JUnit 5 Tests
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;JUnit 5&lt;/strong&gt; introduced the following annotations to allows conditional execution of tests.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@EnabledOnOs&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@DisabledOnOs&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@EnabledOnJre&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@DisabledOnJre&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@EnabledForJreRange&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@DisabledForJreRange&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@EnabledIfSystemProperty&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@EnabledIfEnvironmentVariable&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@DisabledIfEnvironmentVariable&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@EnableIf&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@DisableIf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Here is an example of using &lt;code&gt;@EnabledOnOs&lt;/code&gt; and &lt;code&gt;@DisabledOnOs&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;JUnit5ConditionalTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="nd"&gt;@DisabledOnOs&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="no"&gt;OS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;WINDOWS&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;OS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;OTHER&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_disabled_on_windows&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="nd"&gt;@EnabledOnOs&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="no"&gt;OS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;MAC&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;OS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;LINUX&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_enabled_on_unix&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertTrue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="nd"&gt;@Test&lt;/span&gt;
  &lt;span class="nd"&gt;@DisabledOnOs&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;OS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;MAC&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;test_disabled_on_mac&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;assertFalse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I am using a MacBook, and the output looks as follow&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aeXHVNm5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/26fg5n6hhnij0scc3ot9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aeXHVNm5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/26fg5n6hhnij0scc3ot9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For examples of other annotations, please check out these &lt;a href="https://github.com/junit-team/junit5/blob/master/documentation/src/test/java/example/ConditionalTestExecutionDemo.java"&gt;tests&lt;/a&gt;.&lt;/p&gt;


&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Thank you for reading along. Please share your thoughts, suggestions, and feedback in the comments.&lt;/p&gt;

&lt;p&gt;Please Feel free to follow me on dev.to for more articles, &lt;a href="https://twitter.com/rhamedy_"&gt;Twitter&lt;/a&gt;, and join my professional network on &lt;a href="https://www.linkedin.com/in/rhamedy/"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Lastly, I have also authored the following articles that you might find helpful. &lt;/p&gt;

&lt;p&gt;A guide on how to get started with contributing to open source&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/rhamedy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OBUzqy5S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--H7FAzbok--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/202225/537a8230-7d9b-42ba-9508-8d8a2fda1b69.png" alt="rhamedy image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/rhamedy/why-you-should-think-twice-about-contributing-to-open-source-1l4d" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Why you should think twice about contributing to Open Source&lt;/h2&gt;
      &lt;h3&gt;Rafiullah Hamedy ・ Aug 22 '19 ・ 7 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#opensource&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#motivation&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;p&gt;A listing of key habits that in my opinion would help you become a better developer &lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/rhamedy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OBUzqy5S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--H7FAzbok--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/202225/537a8230-7d9b-42ba-9508-8d8a2fda1b69.png" alt="rhamedy image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/rhamedy/key-habits-and-things-i-wish-i-knew-earlier-as-a-developer-2c97" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Key habits and things I wish I knew earlier as a developer&lt;/h2&gt;
      &lt;h3&gt;Rafiullah Hamedy ・ Aug  6 '19 ・ 9 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#career&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#java&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;
 

&lt;p&gt;Finally, a short summary of coding best practices for Java&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="https://medium.com/@rhamedy/a-short-summary-of-java-coding-best-practices-31283d0167d3" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HltFUR5u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/fit/c/96/96/1%2ABf5JmyP8ZbL_xNxHajHajg.jpeg" alt="Rafiullah Hamedy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://medium.com/@rhamedy/a-short-summary-of-java-coding-best-practices-31283d0167d3" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;A short summary of Java coding best practices | by Rafiullah Hamedy | Medium&lt;/h2&gt;
      &lt;h3&gt;Rafiullah Hamedy ・ &lt;time&gt;Aug 18, 2020&lt;/time&gt; ・ 14 min read
      &lt;div class="ltag__link__servicename"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KBvj_QRD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/medium_icon-90d5232a5da2369849f285fa499c8005e750a788fdbf34f5844d5f2201aae736.svg" alt="Medium Logo"&gt;
        Medium
      &lt;/div&gt;
    &lt;/h3&gt;
&lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>java</category>
      <category>testing</category>
      <category>codequality</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Contribution Debt: Why &amp; How to Contribute to Stack Overflow</title>
      <dc:creator>Rafiullah Hamedy</dc:creator>
      <pubDate>Thu, 03 Oct 2019 01:20:24 +0000</pubDate>
      <link>https://dev.to/rhamedy/contribution-debt-why-how-to-contribute-to-stack-overflow-5fag</link>
      <guid>https://dev.to/rhamedy/contribution-debt-why-how-to-contribute-to-stack-overflow-5fag</guid>
      <description>&lt;h2&gt;
  
  
  Why &amp;amp; How to Stop Procrastinating and Start Contributing
&lt;/h2&gt;

&lt;p&gt;Stack Overflow is world’s leading Q&amp;amp;A sites for developers with over 18+ million questions, 28+ million answers and 11+ million users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2g6timzpff0fzyh5i54q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2g6timzpff0fzyh5i54q.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A huge majority of developers use &lt;a href="https://stackoverflow.com/" rel="noopener noreferrer"&gt;Stack Overflow&lt;/a&gt; on daily basis and I would like to share my thoughts on&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why do I contribute?&lt;/li&gt;
&lt;li&gt;How to contribute? &lt;/li&gt;
&lt;li&gt;What are the benefits of contributing? &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/users/1225551/raf" rel="noopener noreferrer"&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fcrqt8168iquj4h07ji1j.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I joined the Stack Overflow community in 2012 and my contributions in the form of answering questions peaked between Nov 2015 — Feb 2016 which attributes to a huge chunk of my reputation score.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I have posted 168 answers and asked 22 questions with a people reach of roughly ~648K&lt;/li&gt;
&lt;li&gt;I have ~5.2K reputation in Stack Overflow, 792 in Drupal Answers and below 200 in other communities&lt;/li&gt;
&lt;li&gt;I have 27 helpful post edits, flags and casted a total of 585 upvote and downvotes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am no rockstar contributor but, do I feel good about it? Ofcourse! I feel great to have been able to contribute back regardless of the quantity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwzbndpu5ie9cahjx1fcs.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwzbndpu5ie9cahjx1fcs.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  Why do I contribute?
&lt;/h1&gt;

&lt;p&gt;Stack Overflow without any doubt has helped me countless times throughout my software development career.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for answers to specific questions&lt;/li&gt;
&lt;li&gt;Clear my confusion about topics&lt;/li&gt;
&lt;li&gt;Quickly learn about a topic instead of going through articles and books when I don’t have enough time&lt;/li&gt;
&lt;li&gt;Come back to my favourite questions and answers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of the above become possible because somebody, somewhere selflessly decided to share their knowledge.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I benefit from other’s contributions and this is good enough reason for me to contribute back and hope that my contributions help others.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I have come across developers who use Stack Overflow on daily basis and some of them have not even bothered to signup. Somebody asked about this in Stack Overflow. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://meta.stackoverflow.com/questions/297527/why-dont-people-sign-up-and-contribute" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fg6kkkja9ohvxuvxill8s.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While the &lt;a href="https://meta.stackoverflow.com/a/297528/1225551" rel="noopener noreferrer"&gt;accepted answer&lt;/a&gt; is not wrong, I still believe that you should sign up regardless of the reasons highlighted in the answer.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember! Signing up is the first step towards contributing back.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fq0kr6suahs6rfz61mxzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fq0kr6suahs6rfz61mxzc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  How to contribute?
&lt;/h1&gt;

&lt;p&gt;Any kind of contribution that leave the community in a better state than you found it is a good form of contribution. For instance, any of the following is a valid form of contribution&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can improve the quality of a post&lt;/li&gt;
&lt;li&gt;Ask good questions that has not already been asked&lt;/li&gt;
&lt;li&gt;Answer question about a topic that you are knowledgeable&lt;/li&gt;
&lt;li&gt;Upvote questions and answers that helped you&lt;/li&gt;
&lt;li&gt;Downvote but, do not forget to share your reasons&lt;/li&gt;
&lt;li&gt;Leave helpful comments&lt;/li&gt;
&lt;li&gt;Vote in the community election&lt;/li&gt;
&lt;li&gt;Motivate others to contribute back&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Ask questions
&lt;/h2&gt;

&lt;p&gt;The Stack Overflow community has come under the spotlight for not being welcoming to new users and questions however, there are many ways that you could ask a meaningful and welcoming question.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fk0g3q3og9a06clhgnrnn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fk0g3q3og9a06clhgnrnn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure to read the necessary guidelines before posting a question. Read it &lt;a href="https://stackoverflow.com/help/minimal-reproducible-example" rel="noopener noreferrer"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ensure that the question has not already been asked. If there are any related questions and does not necessarily solve your use case, then state that in your question.&lt;/li&gt;
&lt;li&gt;When posting a question, be sure to share what you have done so far. This shows that you have put some efforts and done your research.&lt;/li&gt;
&lt;li&gt;Make sure to format your question and use the appropriates tags&lt;/li&gt;
&lt;li&gt;Do not copy/paste class assignments and projects&lt;/li&gt;
&lt;li&gt;Do not cross-post your question to different communities and platforms&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F669bg7br55q0vcgm2f3q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F669bg7br55q0vcgm2f3q.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you make a post, keep an eye on flags and comments and update your post to address the concerns of those who flag your posts.&lt;/p&gt;
&lt;h2&gt;
  
  
  Answer questions
&lt;/h2&gt;

&lt;p&gt;Do not underestimate your ability to answer questions and there are many ways to do that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fam60e6xycxy31sktqxos.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fam60e6xycxy31sktqxos.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am not an expert in any of the above domains but, I know enough and have used it either at work or in side projects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configure your profile by subscribing to tags (i.e. java, typescript, react, etc.) and Stack Overflow will filter questions that match your tags.&lt;/li&gt;
&lt;li&gt;Do not post an answer if your response can be a comment instead.&lt;/li&gt;
&lt;li&gt;Before writing an answer clarify any confusions via comments.&lt;/li&gt;
&lt;li&gt;Keep your environment ready to try something hands-on in order to validate your solution.&lt;/li&gt;
&lt;li&gt;If you quote or copy/paste content from a tutorial, documentation, or another posts then make sure to link the source and give credit where due.&lt;/li&gt;
&lt;li&gt;If you wish to gain more reputation tackle questions with bounties. These questions would require a little more effort.&lt;/li&gt;
&lt;li&gt;If none of the answers to a question resolved your issue then, be sure to post the solution that fixed your case.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Feeyy3tknzkq9pno236nn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Feeyy3tknzkq9pno236nn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Answer your own questions
&lt;/h2&gt;

&lt;p&gt;There will come a time when you won’t find an answer to your question in Stack Overflow. What do you do next?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use your ninja search skills to look for answers to your question.&lt;/li&gt;
&lt;li&gt;Consider posting a question in the Stack Overflow and hope that you get an helpful answer soon.&lt;/li&gt;
&lt;li&gt;While your question is awaiting to be answered, do your research to find out an answer by reading the documentation, articles, books, and other materials.&lt;/li&gt;
&lt;li&gt;If and when you find the answer then go back to your asked question and answer it yourself.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As weird as this sounds, IMO it is basically sharing your knowledge so that the next person who have stumbles upon a similar question could benefit from your findings. This is a &lt;a href="https://stackoverflow.com/users/1225551/raf?tab=questions" rel="noopener noreferrer"&gt;list of questions&lt;/a&gt; that I asked and answered them myself and people have found it to be helpful.&lt;/p&gt;


&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/51180269/how-to-remove-weekend-datetime-gaps-from-x-axis-of-a-financial-chart" rel="noopener noreferrer"&gt;
            How to remove weekend datetime gaps from x-axis of a financial chart?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Jul  4 '18&lt;/span&gt;
            &lt;span&gt;Comments: 1&lt;/span&gt;
            &lt;span&gt;Answers: 7&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/51180269/how-to-remove-weekend-datetime-gaps-from-x-axis-of-a-financial-chart" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          6
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I have a use case where I pull and plot &lt;code&gt;Forex&lt;/code&gt; data in the form of &lt;code&gt;ask and bid&lt;/code&gt; on the graph and this is based on &lt;code&gt;minute, hour or day candlesticks&lt;/code&gt; and I am only plotting the &lt;code&gt;closing&lt;/code&gt; value for &lt;code&gt;bid and ask&lt;/code&gt; as a &lt;code&gt;spline&lt;/code&gt;. &lt;/p&gt;
&lt;h2&gt;Issue&lt;/h2&gt;

&lt;p&gt;The…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/51180269/how-to-remove-weekend-datetime-gaps-from-x-axis-of-a-financial-chart" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I was playing around with financial charts and wanted to remove the weekend datetime from the graph.&lt;/p&gt;


&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/42603177/implement-spring-oauth2-using-jdbc-with-jwt-and-customize-existing-grant-flows-u" rel="noopener noreferrer"&gt;
            Implement Spring OAuth2 using JDBC with JWT and customize existing grant flows using XML based configuration
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Mar  5 '17&lt;/span&gt;
            &lt;span&gt;Comments: 1&lt;/span&gt;
            &lt;span&gt;Answers: 1&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/42603177/implement-spring-oauth2-using-jdbc-with-jwt-and-customize-existing-grant-flows-u" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          2
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I started to use Spring OAuth2 and in the process, I struggled to find relevant tutorials and content mostly because of the following&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I did not want to use Spring Boot&lt;/li&gt;
&lt;li&gt;I did not want to use Java configs rather xml configuration&lt;/li&gt;
&lt;li&gt;I needed to customize Spring OAuth2 grant flows…&lt;/li&gt;
&lt;/ul&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/42603177/implement-spring-oauth2-using-jdbc-with-jwt-and-customize-existing-grant-flows-u" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Likewise, I struggled to find answer to my non-Spring Boot related questions and when I did find the answers then I shared it.&lt;/p&gt;


&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/48634417/how-to-dry-when-using-swagger-ui-and-the-apiresponses-annotations-with-java-spri" rel="noopener noreferrer"&gt;
            How to DRY when using Swagger UI and the ApiResponses annotations with Java Spring endpoints?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Feb  6 '18&lt;/span&gt;
            &lt;span&gt;Comments: 1&lt;/span&gt;
            &lt;span&gt;Answers: 1&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/48634417/how-to-dry-when-using-swagger-ui-and-the-apiresponses-annotations-with-java-spri" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          21
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I like &lt;code&gt;Swagger&lt;/code&gt; because it makes your apis very user friendly. I use &lt;code&gt;Swagger&lt;/code&gt; annotations like&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;@ApiParam &lt;/li&gt;
&lt;li&gt;@ApiResponse | @ApiResponses &lt;/li&gt;
&lt;li&gt;@ApiOperation &lt;/li&gt;
&lt;li&gt;Others &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On endpoints, query params, request params, request body and so on. &lt;/p&gt;

&lt;p&gt;I like to keep my &lt;code&gt;POJO&lt;/code&gt; classes clean and in general I try my best to follow…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/48634417/how-to-dry-when-using-swagger-ui-and-the-apiresponses-annotations-with-java-spri" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I was using Swagger for my APIs and at one point I noticed that each endpoint has around seven (7) swagger annotations. I thought to myself, can I make these annotations reusable?&lt;/p&gt;

&lt;p&gt;The following question was asked way back in 2014 and since a lot has changed and different versions of the framework has been released. None of the answers worked for my use case and I posted my own version of &lt;a href="https://stackoverflow.com/a/47246045/1225551" rel="noopener noreferrer"&gt;answer&lt;/a&gt; and not surprisingly 21 people have found it to be helpful.&lt;/p&gt;


&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/26490967/how-do-i-configure-hikaricp-in-my-spring-boot-app-in-my-application-properties-f" rel="noopener noreferrer"&gt;
            How do I configure HikariCP in my Spring Boot app in my application.properties files?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Oct 21 '14&lt;/span&gt;
            &lt;span&gt;Comments: 6&lt;/span&gt;
            &lt;span&gt;Answers: 18&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/26490967/how-do-i-configure-hikaricp-in-my-spring-boot-app-in-my-application-properties-f" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          123
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I'm trying to set up HikariCP in my Spring Boot (1.2.0.M1) app so I can test using it in place of Tomcat DBCP. I'd like to configure the connection pool in my application.properties file like I was doing with Tomcat, but I can't figure out how I should be doing…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/26490967/how-do-i-configure-hikaricp-in-my-spring-boot-app-in-my-application-properties-f" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Upvoting and downvoting posts
&lt;/h2&gt;

&lt;p&gt;There are many advantages when it comes to upvoting posts such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your vote help rank the posts&lt;/li&gt;
&lt;li&gt;Your upvote shows your appreciation&lt;/li&gt;
&lt;li&gt;Your upvote encourages the author to make more helpful posts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All you have to ask yourself is, did this question or answer help me? If yes, then upvote the question and answer. Simple as that.&lt;/p&gt;

&lt;p&gt;When you downvote, be sure to provide a comment explaining your reasoning and keep an open mind. I have &lt;code&gt;3 downvotes&lt;/code&gt; and &lt;code&gt;566 upvotes&lt;/code&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  What are the benefits of contributing?
&lt;/h1&gt;

&lt;p&gt;In my opinion, it is the right thing to do and that’s is good enough reason.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2z9ycb5xj4etafp5f5pw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F2z9ycb5xj4etafp5f5pw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are some of the benefits of contributing to Stack Overflow vs not contributing&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Give back to the community ❤&lt;/li&gt;
&lt;li&gt;Communicate with other developers&lt;/li&gt;
&lt;li&gt;Share your existing knowledge&lt;/li&gt;
&lt;li&gt;Acquire new knowledge&lt;/li&gt;
&lt;li&gt;Learn how to write effective posts&lt;/li&gt;
&lt;li&gt;Use your Stack Overflow profile elsewhere to promote yourself&lt;/li&gt;
&lt;li&gt;Setup your job preference in Stack Overflow to explore jobs and receive offers&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Thank you for reading. Please feel free to share your ideas, suggestions, feedback and strategies on how to get started and succeed at contributing to Stack Overflow community.&lt;/p&gt;

&lt;p&gt;If contributing to open source interest you then you might find the following article useful.&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/rhamedy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F202225%2F537a8230-7d9b-42ba-9508-8d8a2fda1b69.png" alt="rhamedy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/rhamedy/why-you-should-think-twice-about-contributing-to-open-source-1l4d" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Why you should think twice about contributing to Open Source&lt;/h2&gt;
      &lt;h3&gt;Rafiullah Hamedy ・ Aug 22 '19&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#opensource&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#motivation&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;
 

&lt;p&gt;I also wrote an article on some of the key habits that in my opinion would help you become a better developer.&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/rhamedy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F202225%2F537a8230-7d9b-42ba-9508-8d8a2fda1b69.png" alt="rhamedy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/rhamedy/key-habits-and-things-i-wish-i-knew-earlier-as-a-developer-2c97" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Key habits and things I wish I knew earlier as a developer&lt;/h2&gt;
      &lt;h3&gt;Rafiullah Hamedy ・ Aug 6 '19&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#career&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#java&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;
 

&lt;p&gt;Please follow me for future articles and feel free to add me to your professional network on &lt;a href="https://www.linkedin.com/in/rhamedy" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>opensource</category>
      <category>motivation</category>
    </item>
    <item>
      <title>Why you should think twice about contributing to Open Source</title>
      <dc:creator>Rafiullah Hamedy</dc:creator>
      <pubDate>Thu, 22 Aug 2019 05:01:18 +0000</pubDate>
      <link>https://dev.to/rhamedy/why-you-should-think-twice-about-contributing-to-open-source-1l4d</link>
      <guid>https://dev.to/rhamedy/why-you-should-think-twice-about-contributing-to-open-source-1l4d</guid>
      <description>&lt;h4&gt;
  
  
  7 out of 10 developers contribute to open source and here are some tips and suggestions on how to get started
&lt;/h4&gt;

&lt;p&gt;It’s no secret that Open Source contribution is one of the most sought after skills in tech. In addition to the employment benefits, there are other advantages such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learning and sharing knowledge&lt;/li&gt;
&lt;li&gt;Build and improve your brand’s visibility&lt;/li&gt;
&lt;li&gt;Collaboration and communication with other developers through code reviews and discussions&lt;/li&gt;
&lt;li&gt;Giving back to the community ❤&lt;/li&gt;
&lt;li&gt;Connect with like minded people, find your employee/employees, co-founder, mentor, mentee&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;According to &lt;a href="https://www.eclipse.org/org/value/public/pdf/business_of_open_source_infographic.pdf" rel="noopener noreferrer"&gt;Eclipse Foundation&lt;/a&gt;, Open Source has seen massive investment in recent years.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fy8rui3bkrne1nfma5soq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fy8rui3bkrne1nfma5soq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why should you care?
&lt;/h2&gt;

&lt;p&gt;Looking back to the 2016 StackOverflow &lt;a href="https://insights.stackoverflow.com/survey/2016" rel="noopener noreferrer"&gt;survey&lt;/a&gt;, there is no mention of open source at all however, in 2017 &lt;a href="https://insights.stackoverflow.com/survey/2017#developer-profile-_-program-as-a-hobby" rel="noopener noreferrer"&gt;survey&lt;/a&gt; around 32.7% of respondents claimed to contribute to open source and this figure increased by nearly 10% (to 43.6%) in 2018 &lt;a href="https://insights.stackoverflow.com/survey/2018#developer-profile-_-contributing-to-open-source" rel="noopener noreferrer"&gt;survey&lt;/a&gt; and what is even more interesting is that the % of contributors rose by 20% in 2019 (to 63.3%).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdbp1y5ldgdz7zryq2twn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdbp1y5ldgdz7zryq2twn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;According to a &lt;a href="https://www.slideshare.net/blackducksoftware/2016-future-of-open-source-survey-results" rel="noopener noreferrer"&gt;2016 Future of Open Source Survey Results&lt;/a&gt; by BlackDuck around 67% of participation in open source has been to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fix bugs &lt;/li&gt;
&lt;li&gt;Add new features &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;59% of developers participate in open source to gain competitive edge.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Taking into account the above facts, figures and trends, IMO it’s worth considering open source contribution.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Be the change that you wish to see in the world — Mahatma Gandhi&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Reasons why I failed to contribute earlier?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8as7cvdt68tvjdfkv78c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8as7cvdt68tvjdfkv78c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A majority of us developers love to contribute to open source but, we end up failing to do so for a variety of reasons. Here is a listing of reasons for me&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A majority of educational institutions neither recognize open source contribution as an effective way to learn nor motivate the students to participate — IMO, open source contribution should be part of the curriculum (as assignment, project, etc).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgqc3lz7ysjdu1wiixjvn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgqc3lz7ysjdu1wiixjvn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your geographical location — IMO the country you live in also plays a vital role as highlighted in this &lt;a href="https://medium.com/@hoffa/github-top-countries-201608-13f642493773" rel="noopener noreferrer"&gt;article&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;New year resolution &amp;amp; birthday promises — I have had countless of these but, they never really worked.&lt;/li&gt;
&lt;li&gt;Unrealistic goals — I once decided that I will do at least twenty (20) pull requests to repository such as docker (because I ❤ docker) without taking into account the fact that I did not have the adequate knowledge to do so.&lt;/li&gt;
&lt;li&gt;Job, side projects and life excuses — Following every failure to contribute, I would consult myself that I am doing well in other verticals.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;No matter how small the contribution, if you do it on a regular basis it does make a difference in the long run.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Underestimating my abilities — At times I have looked into existing pull requests and issues and arrived to the conclusion that “This is complex”.&lt;/li&gt;
&lt;li&gt;Ignoring documentation issues — A majority times I have ignored all the documentation related issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvsximhkc1icnwrdai644.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvsximhkc1icnwrdai644.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;My employers didn't care — I would love a job that requires contributing back to the open source community.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Procrastination — Definitely a factor for a variety of reasons.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are some of the main reasons that stopped me from getting started with open source contribution early on.&lt;/p&gt;




&lt;h2&gt;
  
  
  My Motivation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxho5d7auiam9pg86prqq.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxho5d7auiam9pg86prqq.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The main motivation to contribute to open source for me was to become knowledgeable enough to write about it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I have a strong emphasis on knowledge sharing and this is something that I try to do both personally as well as at work in team and organisation level.&lt;/p&gt;

&lt;p&gt;I was working on a side project last year and I learned a few things about encryption, so I wrote about it &lt;a href="https://medium.com/@rhamedy/encryption-decryption-of-data-based-on-users-password-using-pbkdf2-aes-algorithms-592f8c1bb79a" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Few months down the road, I helped write our company’s coding guidelines and used the knowledge to write an &lt;a href="https://medium.com/@rhamedy/a-short-summary-of-java-coding-best-practices-31283d0167d3" rel="noopener noreferrer"&gt;article&lt;/a&gt; about it as well.&lt;/p&gt;

&lt;p&gt;After two articles, I wanted to write about something that I regarded as really important for new devs and students (&lt;a href="https://medium.com/@rhamedy/key-habits-and-things-i-wish-i-knew-earlier-as-a-developer-43c9466a0407" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; version, not metered).&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/rhamedy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F202225%2F537a8230-7d9b-42ba-9508-8d8a2fda1b69.png" alt="rhamedy"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/rhamedy/key-habits-and-things-i-wish-i-knew-earlier-as-a-developer-2c97" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Key habits and things I wish I knew earlier as a developer&lt;/h2&gt;
      &lt;h3&gt;Rafiullah Hamedy ・ Aug 6 '19&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#career&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#java&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;
 

&lt;p&gt;The community loved ❤ the article and received around ~50K views, many thousand claps and comments of appreciation (In Medium - prior to their Paywall).&lt;/p&gt;

&lt;p&gt;The next big article for me was to write about open source contribution (this article) and for that I needed to make a few open source contributions first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F93e60jvsmvo6mkxvb3na.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F93e60jvsmvo6mkxvb3na.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So if you find yourself in the same boat of wanting to contribute and have not yet then, look for that one reason, motivation, purpose, drive, whatever it is.&lt;/p&gt;


&lt;h2&gt;
  
  
  My Contribution Strategy
&lt;/h2&gt;

&lt;p&gt;I decided that I will contribute to a &lt;a href="https://spring.io/" rel="noopener noreferrer"&gt;Spring Framework&lt;/a&gt;, a library that I have used before. I was reading the &lt;strong&gt;Contribution Guidelines&lt;/strong&gt; when I noticed a few broken links so, I created a &lt;a href="https://github.com/spring-projects/spring-security/pull/6522" rel="noopener noreferrer"&gt;pull request&lt;/a&gt; to fix them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fg17nzm298uq75q0erwo7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fg17nzm298uq75q0erwo7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pull request got merged and it felt so good that I decided to keep going however, there was a problem. A majority of GitHub issues (i.e. bugs, first-timer, help-needed, feature) would get picked by other contributors before I even have a chance to express interest.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhlabdu1xuujmupyz0r8n.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhlabdu1xuujmupyz0r8n.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Whenever a process does not produce the desired result for me, I make a change and re-evaluate the results and continue this way until the results are desirable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is what I did&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I subscribed (watched) to the Spring repository&lt;/li&gt;
&lt;li&gt;On my way to work, I would browse through email notifications and show interest via comment on issues that I could tackle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fiiu0vagteobm1ldnj97x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fiiu0vagteobm1ldnj97x.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a result of this strategy, I had a pool of issues to work on. The first enhancement &lt;a href="https://github.com/spring-projects/spring-security/issues/4187" rel="noopener noreferrer"&gt;feature&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag_github-liquid-tag"&gt;
  &lt;h1&gt;
    &lt;a href="https://github.com/spring-projects/spring-security/issues/4187" rel="noopener noreferrer"&gt;
      &lt;img class="github-logo" alt="GitHub logo" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg"&gt;
      &lt;span class="issue-title"&gt;
        Add Clear Site Data to Log Out
      &lt;/span&gt;
      &lt;span class="issue-number"&gt;#4187&lt;/span&gt;
    &lt;/a&gt;
  &lt;/h1&gt;
  &lt;div class="github-thread"&gt;
    &lt;div class="timeline-comment-header"&gt;
      &lt;a href="https://github.com/rwinch" rel="noopener noreferrer"&gt;
        &lt;img class="github-liquid-tag-img" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars0.githubusercontent.com%2Fu%2F362503%3Fv%3D4" alt="rwinch avatar"&gt;
      &lt;/a&gt;
      &lt;div class="timeline-comment-header-text"&gt;
        &lt;strong&gt;
          &lt;a href="https://github.com/rwinch" rel="noopener noreferrer"&gt;rwinch&lt;/a&gt;
        &lt;/strong&gt; posted on &lt;a href="https://github.com/spring-projects/spring-security/issues/4187" rel="noopener noreferrer"&gt;&lt;time&gt;Jan 06, 2017&lt;/time&gt;&lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag-github-body"&gt;
      &lt;p&gt;We should investigate adding Clear Site Data to Spring Security's LogoutHandler implementations. See &lt;a href="https://w3c.github.io/webappsec-clear-site-data/" rel="nofollow noopener noreferrer"&gt;https://w3c.github.io/webappsec-clear-site-data/&lt;/a&gt;&lt;/p&gt;

    &lt;/div&gt;
    &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/spring-projects/spring-security/issues/4187" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;and the pull request for it &lt;/p&gt;


&lt;div class="ltag_github-liquid-tag"&gt;
  &lt;h1&gt;
    &lt;a href="https://github.com/spring-projects/spring-security/pull/6550" rel="noopener noreferrer"&gt;
      &lt;img class="github-logo" alt="GitHub logo" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg"&gt;
      &lt;span class="issue-title"&gt;
        Add Support for Clear Site Data on Logout
      &lt;/span&gt;
      &lt;span class="issue-number"&gt;#6550&lt;/span&gt;
    &lt;/a&gt;
  &lt;/h1&gt;
  &lt;div class="github-thread"&gt;
    &lt;div class="timeline-comment-header"&gt;
      &lt;a href="https://github.com/rhamedy" rel="noopener noreferrer"&gt;
        &lt;img class="github-liquid-tag-img" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Favatars0.githubusercontent.com%2Fu%2F2510933%3Fv%3D4" alt="rhamedy avatar"&gt;
      &lt;/a&gt;
      &lt;div class="timeline-comment-header-text"&gt;
        &lt;strong&gt;
          &lt;a href="https://github.com/rhamedy" rel="noopener noreferrer"&gt;rhamedy&lt;/a&gt;
        &lt;/strong&gt; posted on &lt;a href="https://github.com/spring-projects/spring-security/pull/6550" rel="noopener noreferrer"&gt;&lt;time&gt;Feb 22, 2019&lt;/time&gt;&lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag-github-body"&gt;
      &lt;p&gt;This PR adds support for Clear Site Data HTTP response header. See the issue for more details.&lt;/p&gt;
&lt;p&gt;Fixes #4187&lt;/p&gt;



    &lt;/div&gt;
    &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/spring-projects/spring-security/pull/6550" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I continued in this fashion on a few other issues of type enhancement, bugs and new features resulting in the following PRs&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/spring-projects/spring-security/pull/6623" rel="noopener noreferrer"&gt;Add placeholder support for header tag attributes&lt;/a&gt; — &lt;strong&gt;Spring Security&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/spring-projects/spring-boot/pull/16278" rel="noopener noreferrer"&gt;Add configuration properties for remaining Undertow&lt;/a&gt; — &lt;strong&gt;Spring Boot&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/spring-projects/spring-boot/pull/16331" rel="noopener noreferrer"&gt;Ensure Qualifier with bean name is evaluated when using SpyBean&lt;/a&gt; — &lt;strong&gt;Spring Boot&lt;/strong&gt; — Declined&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/elastic/elasticsearch/pull/39605" rel="noopener noreferrer"&gt;Convert PluginPropertiesExtension Groovy to Java&lt;/a&gt; — &lt;strong&gt;ElasticSearch&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/spring-projects/spring-security/pull/6765" rel="noopener noreferrer"&gt;Added Support for RFC 8414 OAuth 2.0 Authorization Server Metadata&lt;/a&gt; — &lt;strong&gt;Spring Security&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvrnoqqat31esp5f11sg5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvrnoqqat31esp5f11sg5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, if you are struggling to find issues to work on, pivot to a different strategy.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tips and Suggestions
&lt;/h2&gt;

&lt;p&gt;Based on my knowledge and experience so far&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Participate in &lt;a href="https://hacktoberfest.digitalocean.com/" rel="noopener noreferrer"&gt;Hacktoberfest&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A must-read &lt;a href="https://opensource.guide/how-to-contribute/" rel="noopener noreferrer"&gt;guide&lt;/a&gt; on “how to contribute”&lt;/li&gt;
&lt;li&gt;Learn Git basics&lt;/li&gt;
&lt;li&gt;Pick a language i.e. Java, JavaScript&lt;/li&gt;
&lt;li&gt;Identify repositories that welcome contributions — Use tools such as &lt;a href="https://www.codetriage.com/" rel="noopener noreferrer"&gt;CodeTriage&lt;/a&gt;, &lt;a href="https://github.com/explore/" rel="noopener noreferrer"&gt;Github Explorer&lt;/a&gt; and &lt;a href="https://firstcontributions.github.io/" rel="noopener noreferrer"&gt;this&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Read the repository policies i.e. contribution guidelines&lt;/li&gt;
&lt;li&gt;Learn the project you want to contribute to&lt;/li&gt;
&lt;li&gt;Contribute in the form of code, documentation, bugs, and new features&lt;/li&gt;
&lt;li&gt;Filter issues based on labels such as help-needed, bug, first-timers, etc.&lt;/li&gt;
&lt;li&gt;Be mindful of others time specially maintainers who help you&lt;/li&gt;
&lt;li&gt;Ensure you have the necessary skills and time to invest&lt;/li&gt;
&lt;li&gt;Follow the discussions in issues and pull requests, see the code changes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Be patient and open to feedback&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I picked an Elastic Search &lt;a href="https://github.com/elastic/elasticsearch/pull/39605" rel="noopener noreferrer"&gt;issue&lt;/a&gt; and &lt;strong&gt;ignored&lt;/strong&gt; the fact that I needed to know some Groovy and how Elastic Search build worked as a consequence I spent a lot more time and effort in getting the PR to completion stage.&lt;/p&gt;

&lt;p&gt;It’s always a good idea to do some research before opting to work on an issue.&lt;/p&gt;




&lt;h2&gt;
  
  
  Recommended Reading
&lt;/h2&gt;

&lt;p&gt;I would highly encourage you to read the open source &lt;a href="https://opensource.guide/how-to-contribute/" rel="noopener noreferrer"&gt;guide&lt;/a&gt;, and this &lt;a href="https://www.freecodecamp.org/news/the-definitive-guide-to-contributing-to-open-source-900d5f9f2282/" rel="noopener noreferrer"&gt;article&lt;/a&gt; that comes with a wealth of knowledge on how to get started. This &lt;a href="https://medium.com/mindsdb/contributing-to-an-open-source-project-how-to-get-started-6ba812301738" rel="noopener noreferrer"&gt;article&lt;/a&gt; highlights some good tips and if you are a visual person then these &lt;a href="https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github" rel="noopener noreferrer"&gt;videos&lt;/a&gt; by Kent C. Dodds might be helpful.&lt;/p&gt;

&lt;p&gt;I saw this article on &lt;a href="https://dev.to/integerman/how-to-contribute-to-open-source-software-4pbl"&gt;Open Source Contribution&lt;/a&gt; on Jan 27, 2020 and find it to be a helpful and relevant read.&lt;/p&gt;




&lt;p&gt;Thank you for reading. Please feel free to follow me on here for more articles, connect on &lt;a href="https://www.linkedin.com/in/rhamedy/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and other social media platforms of your choice.&lt;/p&gt;

&lt;p&gt;If this article in any manner helped you in making your first contribution, then you are welcome to share your ideas, suggestions, feedback and pull request as a comment.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>motivation</category>
    </item>
    <item>
      <title>Key habits and things I wish I knew earlier as a developer</title>
      <dc:creator>Rafiullah Hamedy</dc:creator>
      <pubDate>Tue, 06 Aug 2019 05:25:22 +0000</pubDate>
      <link>https://dev.to/rhamedy/key-habits-and-things-i-wish-i-knew-earlier-as-a-developer-2c97</link>
      <guid>https://dev.to/rhamedy/key-habits-and-things-i-wish-i-knew-earlier-as-a-developer-2c97</guid>
      <description>&lt;h5&gt;
  
  
  A listing of key habits and skills that could help you become a better developer
&lt;/h5&gt;

&lt;p&gt;What are some of the things that you wish you knew earlier as a developer? Any habit, book, article or skill? &lt;strong&gt;Please share in the comment section&lt;/strong&gt;. &lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;Here is a quick summary of habits and things that in my opinion would make a huge difference if known earlier as a developer. Of course, &lt;strong&gt;It is never too late&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Efficient use of search engines&lt;/li&gt;
&lt;li&gt;Use modern IDE for increased productivity&lt;/li&gt;
&lt;li&gt;Learn Linux&lt;/li&gt;
&lt;li&gt;Learn Git&lt;/li&gt;
&lt;li&gt;Coding standards matter&lt;/li&gt;
&lt;li&gt;Teach yourself &amp;amp; follow tech trends&lt;/li&gt;
&lt;li&gt;Listen to tech podcasts&lt;/li&gt;
&lt;li&gt;Become proficient in at least one programming language&lt;/li&gt;
&lt;li&gt;Focus on Simplicity&lt;/li&gt;
&lt;li&gt;Learn Design Patterns&lt;/li&gt;
&lt;li&gt;Join communities/forums&lt;/li&gt;
&lt;li&gt;Create professional profiles&lt;/li&gt;
&lt;li&gt;Ask, Ask, Ask&lt;/li&gt;
&lt;li&gt;Solve it in paper first then convert into code&lt;/li&gt;
&lt;li&gt;Document and write tests from start&lt;/li&gt;
&lt;li&gt;Solve puzzles/challenges on regular basis&lt;/li&gt;
&lt;li&gt;Start whiteboarding early on&lt;/li&gt;
&lt;li&gt;Manage your time efficiently&lt;/li&gt;
&lt;li&gt;Protect your personal information&lt;/li&gt;
&lt;li&gt;Follow influencers &amp;amp; companies that inspire you&lt;/li&gt;
&lt;li&gt;Attend tech events, workshops, talks, and hackathons&lt;/li&gt;
&lt;li&gt;Embrace error messages ❤&lt;/li&gt;
&lt;li&gt;Choose the right type of company for internship/career&lt;/li&gt;
&lt;li&gt;First develop a working solution then perfect it iteratively&lt;/li&gt;
&lt;li&gt;SEO yourself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As as usual watch out for the following habits/patterns&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do not give up so easy! ❤&lt;/li&gt;
&lt;li&gt;Do not copy assignments/projects&lt;/li&gt;
&lt;li&gt;Do not procrastinate — if not now, when?&lt;/li&gt;
&lt;li&gt;Do not ignore other subjects&lt;/li&gt;
&lt;li&gt;Do not get addicted to social networks&lt;/li&gt;
&lt;li&gt;Do not lose hope&lt;/li&gt;
&lt;/ul&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--mRoBcYm5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1088680680547143680/nAsnhhcy_normal.jpg" alt="mpj 💛 profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        mpj 💛
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="comment-mentioned-user" href="https://dev.to/mpjme"&gt;@mpjme&lt;/a&gt;

      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      New programmers are often uncertain if they will ever be good enough. As we grow more experienced, we learn to relax in the total certainty that we'll never be good enough.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      17:44 PM - 12 Jun 2018
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1006593168459141121" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1006593168459141121" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      2036
      &lt;a href="https://twitter.com/intent/like?tweet_id=1006593168459141121" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      5900
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;





&lt;h1&gt;
  
  
  Learning
&lt;/h1&gt;

&lt;p&gt;Learning is a prerequisite to thriving in tech due to the speed at which the industry is evolving. There is always something new to learn.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Once you stop learning, you start dying — Albert Einstein&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Search efficiently
&lt;/h3&gt;

&lt;p&gt;As a developer, you will use search engines very often and a majority of search engines offer advanced features. See &lt;a href="https://www.lifehack.org/articles/technology/20-tips-use-google-search-efficiently.html"&gt;tips&lt;/a&gt; and &lt;a href="https://mashable.com/2011/11/24/google-search-infographic/#KSYNRsvFuGqG"&gt;infographics&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Development IDEs
&lt;/h3&gt;

&lt;p&gt;IDEs such as IntelliJ, Atom come with shortcuts, plugins and features aimed to increase your productivity. Invest a little time to learn how to best use an IDE. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cxkbBmcC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3m0nco0f98g3sg24n9kz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cxkbBmcC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3m0nco0f98g3sg24n9kz.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Learn Linux
&lt;/h3&gt;

&lt;p&gt;Installing &lt;a href="https://www.ubuntu.com/"&gt;Ubuntu&lt;/a&gt; natively, using &lt;a href="https://www.virtualbox.org/"&gt;VirtualBox&lt;/a&gt; or &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10"&gt;Windows Subsystem&lt;/a&gt; for Linux is a piece of cake. Linux/Unix knowledge is a huge plus.&lt;/p&gt;
&lt;h3&gt;
  
  
  Learn Git
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://git-scm.com/"&gt;Git&lt;/a&gt; is one of the most popular code versioning tool. I suggest start &lt;strong&gt;Git-ing&lt;/strong&gt; as early as possible with your projects and assignments. A great way to learn &lt;strong&gt;Git&lt;/strong&gt; is through documentation, article and maybe this &lt;a href="https://learngitbranching.js.org/"&gt;interactive online&lt;/a&gt; resource. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lo2EFhUy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/f4k32j5p354m8s0ccptb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lo2EFhUy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/f4k32j5p354m8s0ccptb.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Teach Yourself
&lt;/h3&gt;

&lt;p&gt;It is a fact that your program of study does not prepare you for real world regardless of university’s ranking, depth of the curriculum or caliber of the professors. Nowadays there is no shortage of learning materials both offline and online.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b9OCr45---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1l1ew7iy0pa2bnh62moi.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b9OCr45---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/1l1ew7iy0pa2bnh62moi.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.crunchzilla.com/"&gt;crunchzilla&lt;/a&gt; is a step by step how to code games for beginners. My favourite Youtube channels are &lt;a href="https://www.youtube.com/channel/UCwRXb5dUK4cvsHbx-rGzSgw"&gt;Derek Banas&lt;/a&gt;, &lt;a href="https://www.youtube.com/user/learncodeacademy"&gt;LearnCode Academy&lt;/a&gt;, &lt;a href="https://www.youtube.com/channel/UC8butISFwT-Wl7EV0hUK0BQ"&gt;FreeCodeCamp&lt;/a&gt; and &lt;a href="https://www.youtube.com/channel/UCtxCXg-UvSnTKPOzLH4wJaQ"&gt;CodingTech&lt;/a&gt;. Finally, a listing of open courseware on &lt;a href="https://www.edx.org/"&gt;EDX&lt;/a&gt;, &lt;a href="http://online.stanford.edu/"&gt;Stanford Online&lt;/a&gt;, and &lt;a href="https://ocw.mit.edu/index.htm"&gt;MIT OpenCourseWare&lt;/a&gt; that you could learn from.&lt;/p&gt;
&lt;h3&gt;
  
  
  Learn at least one language concretely
&lt;/h3&gt;

&lt;p&gt;At university, I studied C Programming for 2 years from Basics to Advanced Data Structure. It helped build a strong programming foundation and every other language become a mere change of syntax, terminology and structure.&lt;/p&gt;
&lt;h3&gt;
  
  
  Focus on Simplicity
&lt;/h3&gt;

&lt;p&gt;You will be surprised how in-demand simplicity is when it comes to coding and no one admires code that is complex, hard to understand and maintain.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Simplicity is a prerequisite for reliability. — Edsger W. Dijkstra&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/rI8tNMsozo0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Coding Standards Matter
&lt;/h3&gt;

&lt;p&gt;It is very common for code to migrate from one dev to another over it is lifespan. It's critical to follow a commonly adopted coding guidelines to ensure that the code is easy to understand, extend and maintain. Click the image below to read my article on &lt;strong&gt;Java Coding Best Practices&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@rhamedy/a-short-summary-of-java-coding-best-practices-31283d0167d3"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FYcfgbe_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/700/1%2AI7t4xyisUgXelYijbRegyQ.png" alt="Foo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Learn Design Patterns
&lt;/h3&gt;

&lt;p&gt;Similar to coding standards, knowledge of design patterns help you architect close to &lt;strong&gt;immortal&lt;/strong&gt; systems (ok maybe not immortal, but you get the point).&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v9jnSK61--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dtv0rvbhz4p4x2y4b517.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v9jnSK61--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dtv0rvbhz4p4x2y4b517.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Listen to tech podcasts
&lt;/h3&gt;

&lt;p&gt;Podcast are great ways to broaden your technical knowledge when commuting, walking, driving and so on. I would &lt;strong&gt;highly&lt;/strong&gt; recommend checking out the &lt;a href="https://softwareengineeringdaily.com"&gt;Software Engineering Daily&lt;/a&gt; podcast. &lt;/p&gt;


&lt;h1&gt;
  
  
  Communities &amp;amp; Profiles
&lt;/h1&gt;

&lt;p&gt;Communities are where you network with like minded professionals, learn and give back.&lt;/p&gt;
&lt;h3&gt;
  
  
  GitHub
&lt;/h3&gt;

&lt;p&gt;Creating a profile allow you to setup your own repos, &lt;strong&gt;follow&lt;/strong&gt; inspiring contributors, appreciate others work by &lt;strong&gt;staring&lt;/strong&gt; their repository, and most importantly &lt;strong&gt;contribute&lt;/strong&gt; back to the open source projects. Here is my &lt;a href="https://github.com/rhamedy"&gt;GitHub&lt;/a&gt; profile. &lt;/p&gt;

&lt;p&gt;How to contribute? You can report a &lt;strong&gt;bug&lt;/strong&gt;, write &lt;strong&gt;documentation&lt;/strong&gt;, answer &lt;strong&gt;questions&lt;/strong&gt;, fix &lt;strong&gt;issues&lt;/strong&gt; and create &lt;strong&gt;new features&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It’s worth-mentioning that, employers favour open source contributors.&lt;/em&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  StackOverflow
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/"&gt;StackOverflow&lt;/a&gt; is the largest Software Development Q&amp;amp;A website. A SO profile is good to have. See Rob’s &lt;a href="https://medium.com/@robmuh/i-take-strong-exception-to-every-premise-motivation-and-conclusion-of-this-article-df658bfba8ad"&gt;comment&lt;/a&gt; on its significance in interviews.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ask difficult &amp;amp; meaningful questions&lt;/li&gt;
&lt;li&gt;Answer questions&lt;/li&gt;
&lt;li&gt;Upvote useful questions/answers&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  LinkedIn
&lt;/h3&gt;

&lt;p&gt;A &lt;a href="https://www.linkedin.com/"&gt;LinkedIn&lt;/a&gt; profile is the first step towards building your online presence.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build your professional network&lt;/li&gt;
&lt;li&gt;Subscribe to updates from companies &amp;amp; influencers&lt;/li&gt;
&lt;li&gt;Explore jobs, write and read posts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similarly, &lt;a href="https://angel.co/"&gt;AngelList&lt;/a&gt; and &lt;a href="https://www.indiehackers.com/"&gt;IndieHackers&lt;/a&gt;, Reddit are great communities to be a member of. See my profile below for my profiles. &lt;/p&gt;


&lt;div class="ltag__user ltag__user__id__202225"&gt;
  
    .ltag__user__id__202225 .follow-action-button {
      background-color: #080E3B !important;
      color: #FFFFFF !important;
      border-color: #080E3B !important;
    }
  
    &lt;a href="/rhamedy" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OBUzqy5S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--H7FAzbok--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/202225/537a8230-7d9b-42ba-9508-8d8a2fda1b69.png" alt="rhamedy image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/rhamedy"&gt;Rafiullah Hamedy&lt;/a&gt;
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/rhamedy"&gt;After trying dev.to, I have decided to do a u-turn to medium for my future article.&lt;/a&gt;
    &lt;/div&gt;
    &lt;p class="ltag__user__social"&gt;
        &lt;a href="https://github.com/rhamedy" rel="noopener"&gt;
          &lt;img class="icon-img" alt="github logo" src="https://res.cloudinary.com/practicaldev/image/fetch/s--C74Jn3f1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo.svg"&gt;rhamedy
        &lt;/a&gt;
    &lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;
 


&lt;h1&gt;
  
  
  Habits
&lt;/h1&gt;

&lt;p&gt;Developing a few habits early on would greatly help you down the road. I highly recommend reading The &lt;a href="https://charlesduhigg.com/the-power-of-habit/"&gt;Power of Habit&lt;/a&gt; by Charles Duhigg.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2cuu2b7L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3f0g28bip4a2e9s5ds4h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2cuu2b7L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3f0g28bip4a2e9s5ds4h.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Tech is a fast-paced industry. &lt;strong&gt;Stay up to date&lt;/strong&gt; with social networks &amp;amp; sites such as &lt;a href="https://slashdot.org/"&gt;slashdot&lt;/a&gt; &amp;amp; &lt;a href="https://techcrunch.com/"&gt;techcrunch&lt;/a&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don’t be shy! &lt;strong&gt;Ask for advice&lt;/strong&gt; from those with expertise&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always plan and &lt;strong&gt;solve the problem in paper&lt;/strong&gt; and then write the code. This is very powerful.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write code that aligns with industry adopted &lt;strong&gt;coding standards&lt;/strong&gt;. Start writing tests early for assignments, projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Develop a habit of &lt;strong&gt;solving puzzles/challenges&lt;/strong&gt; on regular basis. This will serve you dearly whether it’s interview, your job, side project, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Whiteboarding&lt;/strong&gt; skill never let you down whether it is interview, on the job. Probably one of the most overlooked skill.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Understand &lt;strong&gt;how much time you have in your hand&lt;/strong&gt; and use it wisely. Do the math, &lt;strong&gt;calendar block tomorrow&lt;/strong&gt; and use &lt;strong&gt;RescueTime/Toggl&lt;/strong&gt; if you are comfortable with their Privacy Policy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Protect your identity by reading &lt;strong&gt;privacy policies, terms of services&lt;/strong&gt;, using VPN &amp;amp; Encryption, password manager, enabling 2FA, and so on.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;h1&gt;
  
  
  Socializing &amp;amp; Networking
&lt;/h1&gt;

&lt;p&gt;There are many benefits to networking and socializing such as&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WQ1r2jor--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7aqzjr6e6qzwgje7o7eu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WQ1r2jor--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7aqzjr6e6qzwgje7o7eu.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build your professional network&lt;/li&gt;
&lt;li&gt;Get inspired and inspire others&lt;/li&gt;
&lt;li&gt;Learn about the dev communities, jobs, mentoring, volunteering, etc&lt;/li&gt;
&lt;li&gt;Find your co-founders and project partners&lt;/li&gt;
&lt;li&gt;Improve your soft skills i.e. speaking, active listening, and so on.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are well past the era of &lt;strong&gt;one man army&lt;/strong&gt;, it is all about &lt;strong&gt;teamwork&lt;/strong&gt; now. Get to know people of all expertise i.e. legal, finance, sales, marketing and so on. It will come handy in the future be it side projects, change industry, etc.&lt;/p&gt;

&lt;p&gt;If you find networking difficult, I recommend reading self help books i.e. &lt;a href="https://www.goodreads.com/book/show/8520610-quiet"&gt;Quiet: The Power of Introverts in a World That Can’t Stop Talking&lt;/a&gt; and there is a ton of tips and advice on internet.&lt;/p&gt;
&lt;h3&gt;
  
  
  Follow Influencers &amp;amp; Companies
&lt;/h3&gt;

&lt;p&gt;Put social networks into good use. Follow people and companies that inspire and remind you of your dreams and goals. I use social networks to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stay connected with family and friends&lt;/li&gt;
&lt;li&gt;Read updates from companies such Google, Microsoft, Apple, United Nations, Amazon, Netflix, &lt;a href="https://www.linkedin.com/company/spacex/"&gt;SpaceX&lt;/a&gt;, Tesla, and so on.&lt;/li&gt;
&lt;li&gt;Follow public figures like &lt;a href="https://en.wikipedia.org/wiki/Elon_Musk"&gt;Elon Musk&lt;/a&gt;, Bill Gates, Leonardo DiCaprio, &lt;a href="https://stackoverflow.com/users/1/jeff-atwood"&gt;Jeff Atwood&lt;/a&gt;, &lt;a href="https://twitter.com/dan_abramov"&gt;Dan Abramov&lt;/a&gt;, &lt;a href="https://github.com/dsyer"&gt;Dave Syer&lt;/a&gt;, &lt;a href="https://github.com/yyx990803"&gt;Evan You&lt;/a&gt;, &lt;a href=""&gt;Vitalik Buterin&lt;/a&gt; and so on.&lt;/li&gt;
&lt;li&gt;Attend monthly meetups (i.e. &lt;a href="https://hackernest.com/"&gt;Hackernest&lt;/a&gt;), workshops, talks, hackathons&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Side Projects
&lt;/h3&gt;

&lt;p&gt;Act on your ideas. The chances that someone else is thinking about it is very high.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick that great idea and do a feasibility and market research&lt;/li&gt;
&lt;li&gt;Connect with your professional network to find partners &amp;amp; co-founders&lt;/li&gt;
&lt;li&gt;Work in your free time while maintaining a healthy work/life balance &amp;amp; don’t forget to see the idea through completion
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n5_QV2Ua--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/49myb1yp9u7bcaz7dj5p.jpeg" alt=""&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  Researching
&lt;/h1&gt;

&lt;p&gt;As a Software Developer you will be constantly learning and researching. Give yourself the &lt;strong&gt;habit of reading the documentation first&lt;/strong&gt; and if that did not help then search for other learning materials such as examples, tutorials, etc.&lt;/p&gt;
&lt;h3&gt;
  
  
  Error Messages
&lt;/h3&gt;

&lt;p&gt;Don’t be disappointed when you come across an error message. Learn &lt;strong&gt;What is it about? When does it happen?&lt;/strong&gt; and &lt;strong&gt;How to handle it gracefully&lt;/strong&gt;?&lt;/p&gt;
&lt;h3&gt;
  
  
  Choose the right Company
&lt;/h3&gt;

&lt;p&gt;Recently, I came across this &lt;a href="https://medium.com/swlh/advice-to-new-software-developers-ce4444943b9a"&gt;article&lt;/a&gt; by Brenn where he explains the benefits of working for a &lt;strong&gt;Product vs Consulting&lt;/strong&gt; company — Might help decide your next career/internship option.&lt;/p&gt;
&lt;h3&gt;
  
  
  SEO Yourself
&lt;/h3&gt;

&lt;p&gt;Have you ever googled yourself? Is your personal information safe? Is your public information easily accessible? Use the magic of search engine to achieve your objectives whether it’s sharing wisdom, promoting your brand, attracting followers, or spreading awareness.&lt;/p&gt;


&lt;h1&gt;
  
  
  Things you should avoid
&lt;/h1&gt;

&lt;p&gt;It takes time to build and remove habits.&lt;/p&gt;
&lt;h3&gt;
  
  
  Do not give up easily
&lt;/h3&gt;

&lt;p&gt;There are different cues that lead to giving up. As a software developer you will easily come across&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Annoying issues&lt;/li&gt;
&lt;li&gt;Poor legacy code&lt;/li&gt;
&lt;li&gt;Learning other languages, tools, and domain knowledge&lt;/li&gt;
&lt;li&gt;Working with people who have different coding habits, opinion, etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is generally a good habit not to give up and keep trying but, don’t be stubborn and understand when is the right time to let go and move on.&lt;/p&gt;

&lt;p&gt;When it comes to coding, if you are on the verge of giving up, try following&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Take a break and come back later or the next day&lt;/li&gt;
&lt;li&gt;Try solving it on paper&lt;/li&gt;
&lt;li&gt;Ask for help from those with expertise&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Do not copy assignments
&lt;/h3&gt;

&lt;p&gt;When I started my computer science degree, the first C programming assignment was &lt;em&gt;“Write a program that computes x^n (x to power of n) using + (plus) and — (minus) operators where x and n are integers provided by the user”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It took me a long time with no access to internet to find a solution on paper. I learned not to give up and keep trying and the future assignments become easier and easier.&lt;/p&gt;
&lt;h3&gt;
  
  
  Do not fall for social network addiction
&lt;/h3&gt;

&lt;p&gt;Believe it or not, a majority of social networks are powered by algorithms that have one goal — &lt;strong&gt;Increase the ROI for the company using your time&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Do not lose hope, you are smarter than you think
&lt;/h3&gt;

&lt;p&gt;Lastly, feeling hopeless and worried is going to be a frequent visitor and you will have to learn how to deal with it. Here are a few points in your defense&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don’t let knowledge gap make you worry or hopeless — see article below&lt;/li&gt;
&lt;li&gt;Don’t be intimidated by those who are better — You will get there&lt;/li&gt;
&lt;li&gt;Don’t lose hope for not knowing everything i.e. AI, Machine Learning, Blockchain, etc — you will learn them eventually&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://medium.com/@dan_abramov"&gt;Dan Abramov&lt;/a&gt;, one of the developers I follow is the co-creator of famous Redux framework wrote the following &lt;a href="https://overreacted.io/things-i-dont-know-as-of-2018"&gt;article&lt;/a&gt; that I consider a great read.&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--qBbZv2pq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1111627718544764931/x9dG4u6X_normal.jpg" alt="getify profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        getify
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="comment-mentioned-user" href="https://dev.to/getify"&gt;@getify&lt;/a&gt;

      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      20+ yrs dev exp, 8 books w/ 100k+ copies sold, 300k+ hours watched of my videos, 4k+ taught in person...&lt;br&gt;&lt;br&gt;And you know what? I still struggle to get my code to work and it's still a tedious slog. And my code still confuses me the next day.&lt;br&gt;&lt;br&gt;You're not alone in these struggles.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      15:33 PM - 10 Mar 2018
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=972495616600293381" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=972495616600293381" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      2189
      &lt;a href="https://twitter.com/intent/like?tweet_id=972495616600293381" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      6064
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;





&lt;h1&gt;
  
  
  Other Articles
&lt;/h1&gt;

&lt;p&gt;So far, I have written the following articles &lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/rhamedy" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OBUzqy5S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--H7FAzbok--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/202225/537a8230-7d9b-42ba-9508-8d8a2fda1b69.png" alt="rhamedy image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/rhamedy/how-to-load-test-a-developer-s-guide-to-performance-testing-4e8m" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;How to Load Test: A developer’s guide to performance testing&lt;/h2&gt;
      &lt;h3&gt;Rafiullah Hamedy ・ Jul 27 '19 ・ 6 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#testing&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#java&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;including &lt;a href="https://medium.com/@rhamedy/a-short-summary-of-java-coding-best-practices-31283d0167d3"&gt;A short summary of Java coding best practices&lt;/a&gt; on medium.&lt;/p&gt;

&lt;p&gt;This article is a port-over plus some additions and changes of the &lt;a href="https://medium.com/@rhamedy/key-habits-and-things-i-wish-i-knew-earlier-as-a-developer-43c9466a0407"&gt;original article&lt;/a&gt; from medium that has nearly 9K claps. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: None of my medium articles are metered. Paywall is the reason, why I am exploring dev.to&lt;/em&gt; &lt;/p&gt;




&lt;h1&gt;
  
  
  Relevant articles
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Finally, some relevant articles for those who wish to read more. One of my favorite articles on &lt;a href="https://zen-of-programming.com/start-programming/"&gt;25 Tips for New Developers&lt;/a&gt; by Ali&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A must-read article &lt;a href="https://medium.com/swlh/advice-to-new-software-developers-ce4444943b9a"&gt;Advice to new software developers&lt;/a&gt; where he touches on Product vs Consulting company for career/internship.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/@lydiahallie/what-new-developers-should-really-focus-on-9da2eb5cf10c"&gt;What New Developers Should Really Focus On&lt;/a&gt; by Lydia who also wrote another &lt;a href="https://medium.com/@lydiahallie/advice-from-a-19-y-o-girl-software-developer-88737bcc6be5"&gt;article&lt;/a&gt; that might resonate to new developers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some great tips by Stephen on his &lt;a href="https://www.codingdojo.com/blog/7-tips-learn-programming-faster/"&gt;blog post&lt;/a&gt; (Code by hand — my absolute favorite, take breaks when debugging)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Another &lt;a href="https://www.codementor.io/learn-programming/15-ways-to-improve-as-a-junior-developer"&gt;15 Tips for Junior Developers&lt;/a&gt; by Natasha on her blog (Separate your concerns i.e. SRP, write short methods, find a mentor)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some &lt;a href="https://dev.to/emadmokhtar/advice-to-junior-developers-4hhk"&gt;amazing tips&lt;/a&gt; by Emad on his blog (i.e. contribution to open source, asking asking, writing blogs, etc)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you for reading and sharing your comments! Follow and connect with me over social media networks for future articles. &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
      <category>java</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Load Test: A developer’s guide to performance testing</title>
      <dc:creator>Rafiullah Hamedy</dc:creator>
      <pubDate>Sat, 27 Jul 2019 05:39:36 +0000</pubDate>
      <link>https://dev.to/rhamedy/how-to-load-test-a-developer-s-guide-to-performance-testing-4e8m</link>
      <guid>https://dev.to/rhamedy/how-to-load-test-a-developer-s-guide-to-performance-testing-4e8m</guid>
      <description>&lt;h4&gt;
  
  
  How to design and run load tests using Apache JMeter &amp;amp; Taurus
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fr7j2mwtygisfdct8vjww.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fr7j2mwtygisfdct8vjww.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;All code is guilty, until proven innocent. — Anonymous&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Objective
&lt;/h1&gt;

&lt;p&gt;The purpose of this article is to help you design and run load test 👍&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Learn?
&lt;/h1&gt;

&lt;p&gt;As developers we already have the foundational knowledge and with a little effort we could expand our skillset.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your company cannot afford to hire performance engineers&lt;/li&gt;
&lt;li&gt;Not enough testers compared to developers&lt;/li&gt;
&lt;li&gt;The skill &amp;amp; knowledge could help you write better and scalable code&lt;/li&gt;
&lt;li&gt;Less dependant on other’s expertise&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsfy6cad2itj5ldotrkhk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsfy6cad2itj5ldotrkhk.png" alt="Dilbert by Scott Adams"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Load Testing?
&lt;/h1&gt;

&lt;p&gt;While unit &amp;amp; integration tests ensure code is functionally correct, load testing measures its performance which is equally important.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Floxowfb1rb1dpntuepih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Floxowfb1rb1dpntuepih.png"&gt;&lt;/a&gt;&lt;br&gt;
Only a Load Test can shed light into concurrency issues, whether the database queries make good use of indexes instead of a full table scans, where are the bottlenecks, does the application scale efficiently, what is the application’s response time and throughput and so on.&lt;/p&gt;


&lt;h1&gt;
  
  
  Getting Started Apache JMeter
&lt;/h1&gt;

&lt;p&gt;In this section we will design and run &lt;a href="https://jmeter.apache.org" rel="noopener noreferrer"&gt;Apache JMeter&lt;/a&gt; load tests. &lt;/p&gt;
&lt;h2&gt;
  
  
  Environment Setup
&lt;/h2&gt;

&lt;p&gt;For environment, either find a suitable online resource (not recommended), come up with your own simple service (node, python, whatever) or simply use the &lt;a href="https://github.com/rhamedy/tinyservice4loadtest" rel="noopener noreferrer"&gt;web service&lt;/a&gt; provided in this article.&lt;/p&gt;

&lt;p&gt;We will be using a simple java-based spring boot &lt;a href="https://github.com/rhamedy/tinyservice4loadtest" rel="noopener noreferrer"&gt;web service&lt;/a&gt; that exposes four (4) endpoints. The requirement are Java 1.8 and Apache Maven.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/rhamedy/tinyservice4loadtest.git
cd tinyservice4loadtest
mvn spring-boot:run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Apache JMeter
&lt;/h2&gt;

&lt;p&gt;Please go ahead and install Apache JMeter from &lt;a href="https://jmeter.apache.org/download_jmeter.cgi" rel="noopener noreferrer"&gt;download site&lt;/a&gt;, unzip and execute the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apache-jmeter/bin/jmeter.sh       // Linux &amp;amp; MacOS
apache-jmeter/bin/jmeter.bat      // Windows
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flpksh9y0jgubzd5gmgbq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flpksh9y0jgubzd5gmgbq.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Design a Test Plan for Apache JMeter
&lt;/h3&gt;

&lt;p&gt;Let’s load test the following apis&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8080/students/list  - [GET] List students
http://localhost:8080/students/id    - [GET] Get student by id
http://localhost:8080/students       - [POST] Create student
http://localhost:8080/students/id    - [DELETE] Delete student by id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the sample tests for above endpoints are available in the GitHub &lt;a href="https://github.com/rhamedy/tinyservice4loadtest" rel="noopener noreferrer"&gt;repository&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1
&lt;/h4&gt;

&lt;p&gt;Right click on test plan and pick &lt;code&gt;Add &amp;gt; Threads (Users) &amp;gt; Thread Group&lt;/code&gt;. A test plan must have at least 1 Thread Group.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;Number of Threads (users)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Ramp-Up period (in seconds)&lt;/code&gt;. How long to reach the max users?&lt;/li&gt;
&lt;li&gt;How many times or for how long to run the test&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F75f9zotj2v2xxrgp4z0m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F75f9zotj2v2xxrgp4z0m.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2
&lt;/h4&gt;

&lt;p&gt;Let’s specify what to test. Right Click on &lt;code&gt;ThreadGroup&lt;/code&gt; and select &lt;code&gt;Add &amp;gt; Config Elements &amp;gt; HTTP Request Defaults&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Config Elements&lt;/strong&gt; are useful if you wish to share configuration among one or more requests for example i.e. server address, port number, token, etc.&lt;/p&gt;

&lt;p&gt;Let’s fill out the HTTP Request Defaults Config element&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1vg8ivbvcox3eeogqxas.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1vg8ivbvcox3eeogqxas.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also let’s add an &lt;code&gt;HTTP Header Manager&lt;/code&gt; via &lt;code&gt;Add &amp;gt; Config Elements &amp;gt; HTTP Header Manager&lt;/code&gt; for &lt;code&gt;Content-Type&lt;/code&gt; header&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8x2fm2aaielupgw41iyu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8x2fm2aaielupgw41iyu.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3
&lt;/h4&gt;

&lt;p&gt;Let’s configure the http requests, Right Click on the &lt;code&gt;ThreadGroup&lt;/code&gt; and select &lt;code&gt;Add &amp;gt; Sampler &amp;gt; HTTP Request&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the method type i.e.&lt;code&gt;GET&lt;/code&gt; or &lt;code&gt;POST&lt;/code&gt; etc&lt;/li&gt;
&lt;li&gt;What is the api path i.e. &lt;code&gt;/students/list&lt;/code&gt; or &lt;code&gt;/students&lt;/code&gt; etc&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fombgj7g2k5aiv0i8ercy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fombgj7g2k5aiv0i8ercy.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right click to &lt;code&gt;duplicate&lt;/code&gt; a request and update it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7ilver9nusue8bbq4dqn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7ilver9nusue8bbq4dqn.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;Listeners&lt;/code&gt; are used to collect results. Right Click on &lt;code&gt;ThreadGroup&lt;/code&gt; and select &lt;code&gt;Add &amp;gt; Listener &amp;gt; Summary Report&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;The test plans in words, we create an &lt;code&gt;Apache JMeter Test Plan&lt;/code&gt; to &lt;code&gt;Load Test&lt;/code&gt; two apis with &lt;code&gt;50 Users&lt;/code&gt; with a ramp-up for a duration of &lt;code&gt;30 seconds&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you have the &lt;code&gt;tinyservice4loadtest&lt;/code&gt; (or your own) running, then let’s hit the play button and see the results in &lt;code&gt;Summary Report&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fu8w358nyafmr4000w1ps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fu8w358nyafmr4000w1ps.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Run Apache JMeter Test Using CLI
&lt;/h3&gt;

&lt;p&gt;The GUI is not recommended for running complex tests. Let’s open a complex sample test from &lt;a href="https://github.com/rhamedy/tinyservice4loadtest/blob/master/jmeter_scripts/student_service_load_test.jmx" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fibtryy460e097rnpmdgo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fibtryy460e097rnpmdgo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above test plan has more elements&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Random Variable&lt;/code&gt; generates a value between x and y&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Loop Controller&lt;/code&gt; executes the content of loop x times&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To generate a meaningful report we need &lt;code&gt;user.properties&lt;/code&gt; (&lt;a href="https://jmeter.apache.org/usermanual/generating-dashboard.html" rel="noopener noreferrer"&gt;Source&lt;/a&gt;) in the directory where &lt;code&gt;.jmx&lt;/code&gt; test is.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jmeter.reportgenerator.report_title=Apache JMeter Dashboard
jmeter.reportgenerator.overall_granularity=60000
jmeter.reportgenerator.graph.responseTimeDistribution.property.set_granularity=100
jmeter.reportgenerator.apdex_satisfied_threshold=1500
jmeter.reportgenerator.apdex_tolerated_threshold=3000
jmeter.reportgenerator.exporter.html.property.output_dir=/tmp/test-jmeter.reportgenerator.exporter.html.filters_only_sample_series=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the test script using command (output-directory should be empty)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jmeter.sh -n -t loadtest.jmx -l log.jtl -e -o output-directory&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the above command the &lt;code&gt;-n&lt;/code&gt; stands for &lt;code&gt;no gui&lt;/code&gt; the &lt;code&gt;-t&lt;/code&gt; indicates the scripts &lt;code&gt;loadtest.jmx&lt;/code&gt; the &lt;code&gt;-l&lt;/code&gt; is for &lt;code&gt;log.jtl&lt;/code&gt; where &lt;code&gt;-e&lt;/code&gt; and &lt;code&gt;-o&lt;/code&gt; are for reporting.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;output-directory&lt;/code&gt; will contain a bunch of files including an &lt;code&gt;index.html&lt;/code&gt; that opens the graphical results of the test as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6f79hgjj1to6kw7w3gsq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6f79hgjj1to6kw7w3gsq.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this graph the left side is APDEX and the right side is Request summary. The red indicates all our 404 errors and the green is 200 successful requests.&lt;/p&gt;

&lt;p&gt;Some numbers relating to &lt;code&gt;Number of samples, Response time, Throughput&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkobdu070tb06mr09r6td.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkobdu070tb06mr09r6td.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most importantly the &lt;code&gt;Response Time&lt;/code&gt; and &lt;code&gt;Throughput&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fjepjubby16laomzx3qt3.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fjepjubby16laomzx3qt3.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly, it’s worth-mentioning that &lt;code&gt;Apache JMeter&lt;/code&gt; can be configured to listen to a browser’s activity and capture the network request. For details see &lt;a href="https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Getting Started with Taurus
&lt;/h1&gt;

&lt;p&gt;Now that we know how to use &lt;code&gt;Apache JMeter&lt;/code&gt; to run a basic load test, let’s explore &lt;a href="https://github.com/Blazemeter/taurus" rel="noopener noreferrer"&gt;open-source&lt;/a&gt; framework &lt;a href="https://gettaurus.org" rel="noopener noreferrer"&gt;Taurus&lt;/a&gt;. In short, one of the reasons for birth of Taurus was because &lt;code&gt;Apache JMeter&lt;/code&gt; has a steep learning curve and &lt;code&gt;Taurus&lt;/code&gt; make things a lot simpler.&lt;/p&gt;

&lt;p&gt;Taurus is an abstraction layer (or a wrapper) on top of Apache JMeter and that means you can run an Apache JMeter script using Taurus. So go ahead and install Taurus using the easy to &lt;a href="https://gettaurus.org/install/Installation" rel="noopener noreferrer"&gt;install instruction&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Taurus&lt;/code&gt; scripts can be written in &lt;code&gt;YAML&lt;/code&gt; or &lt;code&gt;JSON&lt;/code&gt; using follow blocks&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwu4ahlrs1npok86lnpzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwu4ahlrs1npok86lnpzc.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Scenarios&lt;/code&gt; is basically where one or more requests are defined. For each &lt;code&gt;scenario&lt;/code&gt; an &lt;code&gt;execution&lt;/code&gt; is defined with props such as &lt;code&gt;no of users&lt;/code&gt;, &lt;code&gt;duration&lt;/code&gt;, &lt;code&gt;ramp-up period&lt;/code&gt; and so on. The &lt;code&gt;modules&lt;/code&gt; allow us to configure &lt;code&gt;executor&lt;/code&gt; that could be &lt;code&gt;Apache JMeter&lt;/code&gt;, &lt;code&gt;Selenium&lt;/code&gt; and so on. Likewise, the &lt;code&gt;reporting&lt;/code&gt; allows configuring how the report should be generated i.e. csv, live reporting in console, or push the result to the blazemeter website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scenarios: 
 StudentList: 
  requests: 
   - url: http://localhost:8080/students/list
     label: Student List
execution: 
 - scenario: StudentList 
   concurrency: 15
   ramp-up: 2s
   hold-for: 10s
reporting:
 - module: console 
 - module: final-stats 
   summary: true 
   percentiles: true
   test-duration: true 
   dump-csv: single_scenario_single_req.csv

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Load test &lt;code&gt;/students/list&lt;/code&gt; api reaching &lt;code&gt;15&lt;/code&gt; users within &lt;code&gt;2s&lt;/code&gt; (ramp-up) for a duration of &lt;code&gt;10s&lt;/code&gt; and display &lt;code&gt;live result&lt;/code&gt; in the console as well as &lt;code&gt;csv&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;To run the Taurus test (sample provided &lt;a href="https://github.com/rhamedy/tinyservice4loadtest/tree/master/taurus_scripts" rel="noopener noreferrer"&gt;here&lt;/a&gt;), simply run the command bzt &lt;code&gt;test.yaml&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F51mq2lhg57sapc72fyy4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F51mq2lhg57sapc72fyy4.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a &lt;code&gt;Taurus&lt;/code&gt; test you can also configure a scenario to point to an &lt;code&gt;Apache JMeter&lt;/code&gt; script and override execution and other parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scenarios: 
 JMeterExample: 
  script: student_crud_jmeter.jmx

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Taurus&lt;/code&gt; seems to be a very interesting framework and it is worth checking it out. It is very well-documented &lt;a href="https://gettaurus.org/docs/Index" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I highly recommend checking out &lt;a href="https://jmeter.apache.org" rel="noopener noreferrer"&gt;Apache JMeter&lt;/a&gt; and &lt;a href="https://gettaurus.org/?source=post_page---------------------------" rel="noopener noreferrer"&gt;Taurus&lt;/a&gt; documentations if you wish you learn more techniques and tricks.&lt;/p&gt;

&lt;p&gt;Read some of my other articles on &lt;a href="https://medium.com/@rhamedy" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I am thinking of moving away from Medium because of their Paywall. I see a huge difference in stats of my stories before and after introduction of the Paywall. I prefer my articles to be accessible at no cost.  &lt;/p&gt;

&lt;p&gt;Feel free to connect and follow me on your favourite social media for future articles. &lt;/p&gt;

</description>
      <category>testing</category>
      <category>beginners</category>
      <category>java</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
