Ejemplo n.º 1
0
  @Test
  public void exerciseTestedObjectAgain(@Injectable("Another test") String text) {
    assertThatGeneratedSubclassIsAlwaysTheSame();
    assertEquals(123, tested.getValue());
    assertEquals("Another test", tested.name);

    assertFalse(tested.doSomeOperation());

    new FullVerificationsInOrder() {
      {
        tested.run();
        tested.doSomething();
      }
    };
  }
Ejemplo n.º 2
0
  void assertThatGeneratedSubclassIsAlwaysTheSame() {
    Class<?> testedClass = tested.getClass();

    if (generatedSubclass == null) {
      generatedSubclass = testedClass;
    } else {
      assertSame(generatedSubclass, testedClass);
    }
  }
Ejemplo n.º 3
0
  @Test
  public void exerciseTestedObject(@Injectable("Test") String name) {
    assertThatGeneratedSubclassIsAlwaysTheSame();
    assertEquals(123, tested.getValue());
    assertEquals("Test", tested.name);

    new Expectations() {
      {
        tested.doSomething();
        result = 23;
        times = 1;
      }
    };

    assertTrue(tested.doSomeOperation());

    new Verifications() {
      {
        tested.run();
      }
    };
  }
Ejemplo n.º 4
0
  @Test
  public void exerciseDynamicallyMockedTestedObject() {
    assertThatGeneratedSubclassIsAlwaysTheSame();
    assertEquals(123, tested.getValue());

    new Expectations(tested) {
      {
        tested.getValue();
        result = 45;
        tested.doSomething();
        result = 7;
      }
    };

    assertEquals(45, tested.getValue());
    assertTrue(tested.doSomeOperation());

    new Verifications() {
      {
        tested.run();
        times = 1;
      }
    };
  }