Mocking tools for Unit Testing

Hello everyone!

Does anyone know of a library that can be used to create Mock objects for Objectscript classes?

Right now, my team has been building mock objects by hand to help circumvent dependencies when writing and executing unit tests, but I always wondered if someone had ever created a Mock library like Mockito to help quicken the process. 

Thanks!

  • + 3
  • 0
  • 329
  • 2
  • 1

Answers

I indeed did write this framework and also did a presentation of it (it is in the repo). I am writing a more complete article that I expect to publish in about two weeks.

To get you started, there are several examples as well as detailed explanation in the powerpoint presentation.

Kind regards

AC

Comments

At the moment we mock pretty infrequently. We're doing so manually by subclassing and overriding the method implementation. I imagine you could create a generic mock object for any method with nice syntax sugar using the Dynamic Dispatch methods.

One of the showstoppers we have with mocking in objectscript is that it is not global - ie. we can't mock classes called by the implementation (without doing some sort of dependency injection) and there's no way at all to mock calls into routines. Anyone have any thoughts on overcoming these limitations?