title: Access method variable in jUnit test
body: <p>How can I use 2 variable from method below in jUnit test, but Eclipse tells me that I cannot access this variable. How can I make it accesible in any way? Or I need to define tests in other class?</p>
  
  <pre><code>import org.junit.Assert;
  import org.junit.*;
  
  public class Sequence {
  
      public void MissingNumber() {  
          int[] arr = {1, 2, 3, 5, 6, 7, 8};  
          int length = arr.length;  
  
          int indexes = 8;
          int values = 0;  
  
          for (int i = 0; i &lt; length; i++) {  
              indexes += i+1;  
              values += arr[i];  
  
              int result = indexes - values;  
  
              System.out.println("Indexes:" + indexes);
              System.out.println("Values:" + values);
              System.out.println("Missing number is: "+ result);  
          }
      }
  
      @Test
      public void testCase1() {
          Assert.assertEquals("4", result); //need to use result
      }
  
      @Test
      public void testCase2() {
          Assert.assertEquals("10", values); //need to use values
      }
  }
  </code></pre>