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

Add a require('testdouble').explain function #12

Closed
searls opened this issue Sep 8, 2015 · 0 comments
Closed

Add a require('testdouble').explain function #12

searls opened this issue Sep 8, 2015 · 0 comments

Comments

@searls
Copy link
Member

searls commented Sep 8, 2015

One thing that's always tough is debugging dynamic test doubles, in part b/c it can be problematic for them to implement a toString function of their own, and in part because any descriptors or names need to be provided to them by the caller (since they're not typically mirroring a known type). Additionally, we'll want to expose some metadata without adding methods or properties to the test double itself.

What if we had a top-level explain function that took a test double object and returned some nice descriptors:

td = require('testdouble')
myDouble = td.create()

td.explain(myDouble)

Might return:

{
  description: "This test double has 0 stubbings and has been called 0 times.",
  callCount: 0
  calls: []
}
td.when(myDouble(8,9,10).thenReturn(11)
td.explain(myDouble)

Might return:

{
  description: 
     "This test double has 1 stubbing and has been invoked 0 times. \n"+
     "\n"+
     "Stubbings: \n" +
     "  when called with (8,9,10) then return 11 \n" 
  callCount: 0
  calls: []
}
@searls searls mentioned this issue Sep 8, 2015
@searls searls closed this as completed in bc2c136 Sep 8, 2015
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