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

Failed test output improvement suggestion for called.withArg(arg) & called.withArgs(arg) #62

Open
jamesmorgan opened this issue Feb 26, 2016 · 6 comments

Comments

@jamesmorgan
Copy link
Contributor

It would be great if when using called.withArg(arg) & called.withArgs(arg) it produced output which was not expected true but was false.

Ideally it would be nice if the output was what it was actually call with.

@jamlen
Copy link
Member

jamlen commented Feb 26, 2016

If you called it many times should it output all the calls?

var logger = deride.stub(['info']);
//...
logger.info('Something', { message: 'a message', code: 123}, {a: 123, b: 'a long string in here'});
logger.info('Another call to Info', { message: 'another message', code: 123456}, {a: 123234, b: 'another long string in here'});
// many other calls to logger.info
//...
logger.info('talula');
logger.expect.info.called.withArgs('talula');

What should it output?

@jamesmorgan
Copy link
Contributor Author

Maybe something like this: expected the 2nd call to have been invoked with X and not Y ...?

@jamlen
Copy link
Member

jamlen commented Feb 26, 2016

Well you could use:

https://github.com/guzzlerio/deride#provide-access-to-individual-calls-to-a-method

var bob = deride.wrap(bob);
bob.greet('jack', 'alice');
bob.greet('bob');
bob.expect.greet.invocation(0).withArg('alice');
bob.expect.greet.invocation(1).withArg('bob');

@jamesmorgan
Copy link
Contributor Author

Ye that would work, it would be still be nice to give better feedback on failure when using withArg[s]() 👍

@jamlen
Copy link
Member

jamlen commented Feb 29, 2016

For something that gets called once, twice or a relatively small number it would be good to say:

Expected <method> to be called with arg: <arg> but was called with:

0: 'bob',
1: 'talula',
2: { a: 123, b: 'weqrewr'}

but if you have something that is called a lot of times like a logger that would spam the output....

So after 5 distinct calls collapse into logger was called 165 times with different values

How about that?

@jamesmorgan
Copy link
Contributor Author

Ye sounds like a good plan. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants