Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMock API proposal #6

Open
ChristianSchwarz opened this issue Jul 2, 2018 · 0 comments
Open

XMock API proposal #6

ChristianSchwarz opened this issue Jul 2, 2018 · 0 comments

Comments

@ChristianSchwarz
Copy link
Owner

ChristianSchwarz commented Jul 2, 2018

XMock API proposal

Stubbing

callsTo(()->mock.foo(1, gt(5)))   //E
     .willReturn(xyz)                //A
     .callNumber(5)                      //E
            .ifCalledFrom(Thread)  //S
            .willThrow(IOException::new) //A
         
     .everyCallAfterNumber(6)  //E
                 .withDelay(Duration);  //S
                 .willReturn(xyz)      //A

 callsTo(()->mock.foo(1, gt(5))).shouldReturn(ReturnValueProvider); //DEEP_STUBS, SMART_NULLS

 callsTo(()->mock.foo(1, gt(5))).doReturn(xyz);

callsTo(()->mock:foo).

Assertions

assertThat(()->mock.foo(1, gt(5))).wasCalled(); //was called at least once
assertThat(()->mock.foo(1, gt(5))).wasCalled(times(5));
assertThat(()->mock1.foo(1, gt(5))).wasCalled(times(5));
inOrder(()->{  //no need to specify
  assertThat(()->mock.foo(1, gt(5))).wasCalled(atLeast(2).andAtMost(6))
  assertThat(mock::bar)).wasCalled(by(currentThread()))
  assertThat(()->mock.foo()).wasCalled(from(expectedInstanceOrMethod)) //Java9 Stacktrace API required
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant