title: Use Mockito to mock some methods but not others
body: <p>Is there any way, using Mockito, to mock some methods in a class, but not others?</p>
  
  <p>For example, in this (admittedly contrived) <code>Stock</code> class I want to mock the <code>getPrice()</code> and <code>getQuantity()</code> return values (as shown in the test snippet below) but I want the <code>getValue()</code> to perform the multiplication as coded in the <code>Stock</code> class</p>
  
  <pre><code>public class Stock {
    private final double price;
    private final int quantity;
  
    Stock(double price, int quantity) {
      this.price = price;
      this.quantity = quantity;
    }
  
    public double getPrice() {
      return price;
    }
  
    public int getQuantity() {
      return quantity;
    }
    public double getValue() {
      return getPrice() * getQuantity();
    }
  
    @Test
    public void getValueTest() {
      Stock stock = mock(Stock.class);
      when(stock.getPrice()).thenReturn(100.00);
      when(stock.getQuantity()).thenReturn(200);
      double value = stock.getValue();
      // Unfortunately the following assert fails, because the mock Stock getValue() method does not perform the Stock.getValue() calculation code.
      assertEquals("Stock value not correct", 100.00*200, value, .00001);
  }
  </code></pre>