質問

I user TestNG and jMock for my unit test but, I have a problem with TestNG. It marks the test as passed when I expect mock object method to be invoked and it is not!

public class SomeTestTest {


  Mockery mocker = new Mockery();

  SomeInterface someInterface = mocker.mock(SomeInterface.class);

  @Test
  public void testName() throws Exception {
    mocker.checking(new Expectations() {{
      oneOf(someInterface).someMethod();
    }});
  }
}

and this is the report I get

Custom suite
Total tests run: 1, Failures: 0, Skips: 0
役に立ちましたか?

解決

You're missing a call to Mockery.assertIsSatisfied().

That call tells jMock when you expect all expectations to be satisfied. Otherwise it wouldn't know at which point in your code you want those to be verified.

That's also explained in the Getting Started article.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top