Ejemplo n.º 1
0
  @Test
  public void personCanBePrinted() throws Exception {
    // Expectancy: define behaviour (a.k.a. "recording")
    when(printer.startPrinting()).thenReturn(true, false);

    assertTrue(person.print(printer));
    verify(printer, times(1)).addToQueue(person);
    verify(printer, times(1)).startPrinting();
    verifyNoMoreInteractions(printer);
  }
Ejemplo n.º 2
0
 @Test
 public void documentCanBePrinted() throws Exception {
   doNothing().when(document).startPrinting();
   person.print(document);
 }
Ejemplo n.º 3
0
 @Test(expected = UnsupportedOperationException.class)
 public void printerNotYetImplemented() throws Exception {
   when(printer.startPrinting()).thenThrow(new UnsupportedOperationException());
   person.print(printer);
 }