All, I have just released DoubleAgents, a library for creating "test doubles" in Visualworks Smalltalk. DoubleAgents is available in the Cincom Public Store Repository. A snapshot of the current version is also on GitHub. The Readme file on GitHub includes high-level documentation if you'd like more information before diving in. The full release announcement is on my blog, Courageous Software. Thanks, Randy Coulman Email: [hidden email]
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Randy,
it looks very interesting. Thanks for making this public. Have you had a look at the framework sMock, too? Could you please point out the main differences? Regards, Steffen Am 30.04.2013, 16:16 Uhr, schrieb Randy Coulman <[hidden email]>: > All, > > I have just released > DoubleAgents<https://github.com/randycoulman/DoubleAgents>, > a library for creating "test doubles" in Visualworks Smalltalk. > > DoubleAgents is available in the Cincom Public Store > Repository<http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository>. > A > snapshot of the current version is also on > GitHub<https://github.com/randycoulman/DoubleAgents>. > The Readme file on GitHub includes high-level documentation if you'd like > more information before diving in. > > The full release announcement is on my blog, Courageous > Software<http://randycoulman.com/blog/2013/04/30/double-agents-a-test-double-library-for-visualworks-smalltalk/> > . > > Thanks, > Randy _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi, Steffen, I wasn't aware of sMock before. Thanks for pointing it out. It looks like a pretty good framework. I haven't worked with it, but I think I like the API better than I like SmallMock's API, which is what I was using before I wrote DoubleAgents. After a brief look, the main differences I see:
What are your thoughts? Randy On Wed, May 1, 2013 at 2:27 AM, Steffen Märcker <[hidden email]> wrote: Hi Randy, Randy Coulman Email: [hidden email]
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Randy,
thanks for the explanation. DoubleAgents appear really interesting to me. I think I'll give it a try soon. Maybe for the reducers stuff or while reworking the SimpleXO / SimpleXPath tests. The latter uses sMock up to now. Do DAs support mocking a class, too? How would you do that? > in-place/partial doubles where you can mock or stub individual methods > on an existing instance or class. Nice. > Unfortunately, though, sMock's TestCase subclasses are both > in the same package, so clients are forced to have both > frameworks loaded at the same time. Mmh, for me sMock works well with only one testing framework loaded. One can safely ignore the error message on load. Though, it would be nice to load the proper test class automagically, dependent on the loaded framework. Regards, Steffen _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
What do you mean by "mocking a class"? Can you give me an example? Thanks, Randy On Tue, May 14, 2013 at 10:12 AM, Steffen Märcker <[hidden email]> wrote: Hi Randy, Randy Coulman Email: [hidden email]
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Say, we have MyClass that defines myMethod on the class side, e.g.
> MyClass class>>myMethod > "fancy stuff" The code to be tested is given that class in some way and uses it, say > result := suspectObject doStuffWithClass: MyClass. Can I stub myMethod with DoubleAgents? Maybe similar to > classDouble := MyClass class doubleAgent. > classDouble stub: #myMethod return: 42. > result := suspectObject doStuffWithClass: classDouble. Regards, Steffen Am 14.05.2013, 20:11 Uhr, schrieb Randy Coulman <[hidden email]>: > What do you mean by "mocking a class"? Can you give me an example? > > Thanks, > Randy > > > On Tue, May 14, 2013 at 10:12 AM, Steffen Märcker <[hidden email]> wrote: > >> Hi Randy, >> >> thanks for the explanation. DoubleAgents appear really interesting to >> me. >> I think I'll give it a try soon. Maybe for the reducers stuff or while >> reworking the SimpleXO / SimpleXPath tests. The latter uses sMock up to >> now. >> >> Do DAs support mocking a class, too? How would you do that? >> >> >> in-place/partial doubles where you can mock or stub individual methods >> on >>> an existing instance or class. >>> >> >> Nice. >> >> >> Unfortunately, though, sMock's TestCase subclasses are both >>> in the same package, so clients are forced to have both >>> frameworks loaded at the same time. >>> >> >> Mmh, for me sMock works well with only one testing framework loaded. One >> can safely ignore the error message on load. Though, it would be nice to >> load the proper test class automagically, dependent on the loaded >> framework. >> >> Regards, Steffen >> vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
OK, I understand what you're looking for. I could think of a couple of interpretations. You basically have two options: 1. You can make a complete double of the class like this:
classDouble := DoubleAgent of: MyClass class. classDouble stub: #myMethod return: 42. result := suspectObject doStuffWithClass: classDouble. If this is a common use case, then I should think about adding some kind of convenience protocol to handle it. 2. You can use an in-place double on the original class like this:
classDouble := MyClass classSideDouble. classDouble stub: #myMethod return: 42. result := suspectObject doStuffWithClass: classDouble. I see the tradeoffs between the two as follows: * The complete double will not respond to any other messages than those you stub or mock; the in-place double will retain its original behavior for any methods that you don't mention.
* The complete double has to be injected into the object under test; the in-place double does not. * The complete double will not impact any other objects that use that class; the in-place double will have a global effect.
Randy On Wed, May 15, 2013 at 2:25 AM, Steffen Märcker <[hidden email]> wrote:
Randy Coulman Email: [hidden email]
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Randy Coulman
Dear Randy,
is there an easy way to check, that no stubbed/mocked methods are left in some MethodDictionary? I somehow managed to have a stubbed method left in the class Array. I have no idea how it got there and had to remove it by hand. I did not (yet) use any in-place class-side doubles. However, I wonder if there are any other classes with zombie methods. Regards, Steffen Am 30.04.2013, 16:16 Uhr, schrieb Randy Coulman <[hidden email]>: > All, > > I have just released > DoubleAgents<https://github.com/randycoulman/DoubleAgents>, > a library for creating "test doubles" in Visualworks Smalltalk. > > DoubleAgents is available in the Cincom Public Store > Repository<http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository>. > A > snapshot of the current version is also on > GitHub<https://github.com/randycoulman/DoubleAgents>. > The Readme file on GitHub includes high-level documentation if you'd like > more information before diving in. > > The full release announcement is on my blog, Courageous > Software<http://randycoulman.com/blog/2013/04/30/double-agents-a-test-double-library-for-visualworks-smalltalk/> > . > > Thanks, > Randy vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
... I mean some automatic way rather than searching manually via
Object>>allSubclasses or MethodDictionary>>allInstances. Am 26.05.2013, 18:14 Uhr, schrieb Steffen Märcker <[hidden email]>: > Dear Randy, > > is there an easy way to check, that no stubbed/mocked methods are left > in some MethodDictionary? I somehow managed to have a stubbed method > left in the class Array. I have no idea how it got there and had to > remove it by hand. I did not (yet) use any in-place class-side doubles. > However, I wonder if there are any other classes with zombie methods. > > Regards, > Steffen > > > Am 30.04.2013, 16:16 Uhr, schrieb Randy Coulman <[hidden email]>: > >> All, >> >> I have just released >> DoubleAgents<https://github.com/randycoulman/DoubleAgents>, >> a library for creating "test doubles" in Visualworks Smalltalk. >> >> DoubleAgents is available in the Cincom Public Store >> Repository<http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository>. >> A >> snapshot of the current version is also on >> GitHub<https://github.com/randycoulman/DoubleAgents>. >> The Readme file on GitHub includes high-level documentation if you'd >> like >> more information before diving in. >> >> The full release announcement is on my blog, Courageous >> Software<http://randycoulman.com/blog/2013/04/30/double-agents-a-test-double-library-for-visualworks-smalltalk/> >> . >> >> Thanks, >> Randy > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Steffen Märcker
Hi Steffen, If you aren't using any in-place doubles, there shouldn't be any stubbed or mocked methods left over. "Normal" doubles don't do anything tricky with method dictionaries. Typically, if you've got something left laying around, doing an If that doesn't work, let me know and I'll see if I can come up with some other ideas for you to try. Randy On Sun, May 26, 2013 at 9:14 AM, Steffen Märcker <[hidden email]> wrote: Dear Randy, Randy Coulman Email: [hidden email]
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |