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

[EasyMock 3.5] Reporting when mock fails #219

Open
nmwael opened this issue Jun 28, 2018 · 5 comments
Open

[EasyMock 3.5] Reporting when mock fails #219

nmwael opened this issue Jun 28, 2018 · 5 comments

Comments

@nmwael
Copy link

nmwael commented Jun 28, 2018

Hi

This could be an improvement or possible an existing feature? We've searched up and down, but only found one way to do this..

When a mock fails this is output:

java.lang.AssertionError:
Unexpected method call readOnlyAllInOneService.getPrompts("159159", "PERSONAL_ADVISER", "INITIALIZING"):
readOnlyAllInOneService.getKeySetup("159159", "PERSONAL_ADVISER"): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 0

We would like more information like this

java.lang.AssertionError:
Unexpected method call readOnlyAllInOneService.getPrompts("159159", "PERSONAL_ADVISER", "INITIALIZING"):
readOnlyAllInOneService.getFlowSettingFromParameterName("159159", "ano", "size"): expected: 1, actual: 1
readOnlyAllInOneService.getKeySetup("159159", "LOGINUSER"): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 1
readOnlyAllInOneService.getFlowSetting("159159", "promptURL"): expected: 1, actual: 1
readOnlyAllInOneService.getKeySetup("159159", "LOGINUSER"): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 1
readOnlyAllInOneService.getPromptsForRetry("159159", "LOGINUSER", "TERMINATOR", 2 (int)): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 1
readOnlyAllInOneService.getPrompts("159159", "LOGINUSER", "Valid"): expected: 1, actual: 1
readOnlyAllInOneService.getKeySetup("159159", "LOGINCODE"): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 1
readOnlyAllInOneService.getPromptsForRetry("159159", "LOGINCODE", "TERMINATOR", 1 (int)): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 1
readOnlyAllInOneService.getPromptsForRetry("159159", "LOGINCODE", "TERMINATOR", 2 (int)): expected: 1, actual: 1
readOnlyAllInOneService.getKeySetup("159159", "LOGINCODE"): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 1
mqConnection.request(matches(".T020."), 566 (int)): expected: 1, actual: 1
readOnlyAllInOneService.getPrompts("159159", "*", "ReturCode050ReasonCode014"): expected: 1, actual: 1
readOnlyAllInOneService.getKeySetup("159159", "LOGINUSER"): expected: 1, actual: 1
CallData.getKeyEntered(): expected: 1, actual: 1
readOnlyAllInOneService.getPrompts("159159", "PERSONAL_ADVISER", "Valid"): expected: 1, actual: 0
readOnlyAllInOneService.getPrompts("159159", "PERSONAL_ADVISER", "transfer"): expected: 1, actual: 0
readOnlyAllInOneService.getPrompts("159159", "PERSONAL_ADVISER", "transfer_NOT_LOGIN"): expected: 1, actual: 0
readOnlyAllInOneService.getFlowSettingFromParameterName("159159", "PERSONAL_ADVISER", "defaultTransferNumber"): expected: 1, actual: 0
readOnlyAllInOneService.getFlowSettingFromParameterName("159159", "PERSONAL_ADVISER", "DefaultGroup"): expected: 1, actual: 0

Only way we found todo this are like so

Set break point in class org.easymock.internal.MocksBehavior

https://github.com/easymock/easymock/blob/master/core/src/main/java/org/easymock/internal/MocksBehavior.java#L132

Method
public final Result addActual(Invocation actual) {

this line (132)
for (int i = initialPosition; i <= endPosition; i++) {

Change to initialPosition = 0
Cange to endPosition = behaviorLists.size()-1

Are there any way to setup reporting for easy mock todo so?

A nice way would be to be able to output something like this (No idea of the implementation it requires) Where all mocks would be listed for each test

Example

@henri-tremblay
Copy link
Contributor

I'm not sure I get what you are asking? In case of an unexpected call, you would like to see all the currently expected calls in the error message?

@nmwael
Copy link
Author

nmwael commented Jul 2, 2018 via email

@nmwael
Copy link
Author

nmwael commented Jul 2, 2018

in short yes.:)

@michael-houmaark
Copy link

Yes, that would be a really nice feature
Any new update ???

@henri-tremblay
Copy link
Contributor

It's probably possible. However, the EasyMock development bandwidth is quite limited these days. So I don't know when it will come out.

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

3 participants