title: JMockit - Expectations vs MockUp<T> Why does one work and the other doesn't?
body: <p>I'm attempting (still) to learn the ins and outs of JMockit.  Here's yet another example of a JMockit oddity I just don't get.  Running the test with NonStrictExpectations works just fine.  However, running with MockUp does not.  I'm not sure why.  Any ideas?  I'm running JMockit 1.5.</p>
  
  <p>Method to test:</p>
  
  <pre><code>private List&lt;Foo&gt; getFooList(List&lt;FooStatement&gt; fooStatements){
      List&lt;Foo&gt; FooList = new ArrayList&lt;Foo&gt;();
  
      for(FooStatement at: fooStatements){
          List&lt;Foo&gt; aList = at.getFoos();
          FooList.addAll(aList);
      }
  
      return FooList;
  }
  </code></pre>
  
  <p>Successful Expectations Test</p>
  
  <pre><code>@Test
  public void getFooListWithExpectationsTest(
          @Mocked final FooStatement mockFooStatement,
          @Mocked final Foo mockFoo
  ){
  
      List&lt;FooStatement&gt; fooStatementList = new ArrayList&lt;&gt;(Arrays.asList(
              mockFooStatement,
              mockFooStatement
      ));
  
      new NonStrictExpectations(){{
          mockFooStatement.getFoos();
          result = new ArrayList&lt;Foo&gt;(Arrays.asList(mockFoo));
      }};
  
      List&lt;Foo&gt; fooList = Deencapsulation.invoke(handler, "getFooList", fooStatementList);
      Assert.assertTrue(fooList.size() == 2);
  }
  </code></pre>
  
  <p>Assertions Error (0 != 2) with MockUp</p>
  
  <pre><code>@Test
  public void getFooListWithMockUpTest(
          @Mocked final FooStatement mockFooStatement,
          @Mocked final Foo mockFoo
  ){
  
      new MockUp&lt;FooStatement&gt;(){
          @Mock
          public List&lt;Foo&gt; getFoos(){
              return new ArrayList&lt;Foo&gt;(Arrays.asList(mockFoo));
          }
      };
  
      List&lt;FooStatement&gt; fooStatementList = new ArrayList&lt;&gt;(Arrays.asList(
              mockFooStatement,
              mockFooStatement
      ));
  
      List&lt;Foo&gt; fooList = Deencapsulation.invoke(handler, "getFooList", fooStatementList);
      Assert.assertTrue(fooList.size() == 2);
  }
  </code></pre>