title: junit test for a method with return type int and parameters as arraylist
body: <p>The following method checks for all triplets with the given value/sum. I want to write a @Test method for this method that returns an integer and also takes in an arraylist and a variable as parameters. Is there a way I can write a junit5 test for the following code-</p>
  <pre><code>int triplets(ArrayList&lt;Integer&gt; a, int sum)
  {
      int l, r;
      int count = 0;
  
      for (int i = 0; i &lt; a.size() - 2; i++) {
  
          l = i + 1;
          r = a.size() - 1;
          while (l &lt; r) {
              if ( a.get(i) + a.get(l) + a.get(r) == sum) {
                  count++;
                  System.out.print(&quot;Triplet &quot; + count +&quot; is &quot; + a.get(i) + &quot;, &quot; + a.get(l) + &quot;, &quot; + a.get(r) + &quot;\n&quot;);
                  l++;
                  r--;
              }
              else if (a.get(i) + a.get(l) + a.get(r) &lt; sum)
                  l++;
  
              else // arr.get(i) + arr.get(l) + arr.get(r) &gt; sum
                  r--;
          }
      }
      if(count!=0)
      {
          System.out.print(&quot;Total triplets present: &quot; + count);
          return 1;
      }
      else
          return -1;
  }
  </code></pre>