title: JUnit testing Try/Catch exception
body: <p>I can't seem to be able to access the Exception in the method for a JUnit test. Here is the method:</p>
  
  <pre><code>public void doUpdateStocks() {
      for (Entry&lt;Integer, IFolioRestricted&gt; e : folioList.entrySet()) {
  
          IFolioRestricted folio = e.getValue();
  
          for(Entry&lt;Integer, IStockRestricted&gt; s : folio.getStockList().entrySet()){
              try {
                  ((IStock) (s.getValue())).updatePrice();
              } catch (MethodException e1) {
                  e1.printStackTrace();
              }
          }
      }
  </code></pre>
  
  <p>And this is how I am testing it:</p>
  
  <pre><code>    @Test
      public void testUpdateStock() {
  
          h.doCreateNewFolio("a");
          try {
              h.doBuyStock(0, "A", 10);
          } catch (IOException | WebsiteDataException | NoSuchTickerException | MethodException e) {
              // TODO Auto-generated catch block
          }
          h.doUpdateStocks();
      }
  </code></pre>
  
  <p>After looking online I have seen (expected = MethodException.class) however it doesn't seem to work. Anyone any ideas on how to cover the catch (MethodException e1) { e1.printStackTrace(); } in a JUnit?</p>