title: Java: Junit tests and ArrayList
body: <p>I just started out with Java in school and have trouble with Junit tests. We were supposed to write a method that checks if a given arraylist is divisable by a given divisor. if the array is empty or the divisor is 0 it's supposed to return false. this is my code:</p>
  
  <pre><code>public class ArrayCheck {
  /**
   * Tests all elements of the given array,
   * if they are divisible by the given divisor.
   *
   * @param arr
   *            array to be tested
   * @param divisor
   *              number by which all elements of the given array should be divisible
   * @return true if all elements are divisible by divisor
   */
  public boolean allDivisibleBy(ArrayList&lt;Integer&gt; arr, int divisor) {
      //check if number is dividable or if number is 0
      for (int i=0; i&lt;arr.size(); i++){
          if (arr.get(i) % divisor==0){
              return true;
          }   
              else if(arr.get(i)==0){
                  return true;
              }
                  //check if divisor is 0
                  else if (divisor==0){
                      return false;
                  }   
      }
      return false;
  }
  }
  </code></pre>
  
  <p>And here is my Junit-test so far. I understand, that i need to create different arraylists to test out my method, however i don't seem to fully understand how to implement these arrays and test them:</p>
  
  <pre><code>import static org.junit.Assert.assertFalse;
  import static org.junit.Assert.assertTrue;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  
  import org.junit.Before;
  import org.junit.Test;
  
  
  public class ArrayCheckTest {
  
  public ArrayCheck ArrayCheck = new ArrayCheck();
  
  ArrayList&lt;Integer&gt; array1=new ArrayList&lt;Integer&gt;();
  array1.add();
  
  
  
      @Test(timeout = 1000)
      public void testAllDivisibleBy() {
  
          ArrayCheck.allDivisibleBy(array1, 2);
      }
  }
  </code></pre>
  
  <p>Any help in understanding Junit-test-implementation better would be appreciated! thanks!</p>