title: Junit: local variables and void methods
body: <p>I'm fairly new to unit testing and have been reading a lot of material online, but I'm having  a little trouble figuring stuff out.</p>
  
  <p>For example: If I have the following piece of code :</p>
  
  <pre><code>public class RandomClass
  {
    int a = 4;
    public void foo(Object obj)
    {
      if(a == 4)
      {
        AnotherObject anotherObj = new AnotherObject();
        anotherObj.setAttribute(obj.getFiled());
        //Method call that will be suppressed 
        Anotherclass.anotherMethod(anotherObj);
      } 
    }
  }
  </code></pre>
  
  <p>I thought of writing my junit test case like this:</p>
  
  <pre><code>@Test
  public void testFoo()
  {
    int a=4;
    RandomClass randomClass = new RandomClass();
    Object object = new Object();
    object.setField("hey");
    randomClass.foo(object);
  }
  </code></pre>
  
  <p>I have a couple of questions here. 
  How exactly do I set the integer a from my junit? The way I'm setting it right now doesn't the unit test case any impact. When I debug the unit test, the value of a is NULL so it never passes the if condition! </p>
  
  <p>Also, the method foo returns a void so what can I possibly test/assert? </p>