title: Need to verify size of an array in unit testing
body: <pre><code>Class Elem{
      private ArrayList&lt;someType&gt; arr = new ArrayList&lt;&gt;();
  
     public void addElement(someType var) {
         arr.add(var);
     }
  
      public someType bestelement() {
          someType first= arr.get(0);
          arr.remove(0);
          return first;
      }
  }
  </code></pre>
  
  <p>I have written test case for this method and it's running successfully but I need to know how can I be sure that the remove() method was called and the size of array list was reduced by 1? Please do tell me how to get the size of arr in my test case? </p>
  
  <p>Test case for this method</p>
  
  <pre><code>Class ElemTest{
      private Elem obj = new Elem();
      private someType var1;
      private someType var2;
      private ArrayList&lt;someType&gt; testArr = new ArrayList&lt;&gt;();
  
      @Test
      public void bestElementTest() {
          obj.addElement(var1);
          obj.addElement(var2);
          testArr.add(var1);
          testArr.add(var2);
          someType result = testArr.get(0);
          assertEquals("test failed", result, obj.bestElem());
      }
  }
  </code></pre>