title: how to unit test a class which creates new objects
body: <p>I'm using JUnit and Mockito to test some classes. The class itself creates an object from another class. A list called testList. Here my code:</p>
  
  <pre><code>public class A {
         private List&lt;B&gt; bList;
  
         //returns the bList
         public List&lt;B&gt; getBList() {
            return bList;
         }
  
         //checks the status by calling getStatus in class B
         public Status getStatus() {
            //status is an enum consists of PASSED and FAILED
            Status finalStatus = Status.PASSED;
            for (B be : this.getTestList()) {
               if (be.getStatus() != Status.PASSED) {
                  finalStatus = Status.FAILED;
                  break;
               }
            }
            return status;
         }
      }
  
  
      public Class B {
         private Status status = Status.FAILED;   
  
         public getStatus() {
            return status;
         }
  
         public void setStatus(Status status) {
            this.status = status;
         }
      }
  </code></pre>
  
  <p>What would be the best way to test the getStatus and getTestList methods in the class called Test.</p>
  
  <p>Thank you very much....</p>