ApexMocks Supported Features

Currently the ApexMocks framework supports the following:

  • verify a method was called with the correct arguments
  • verify a method was called n number of times
  • verify a method was never called
  • stub a method call with a particular set of arguments to return a particular value
  • stub a method call with a particular set of arguments to throw a particular exception

Caveats (given I developed ApexMocks in my free time):

  • somewhat stating the obvious, I haven’t tested ApexMocks with every possible variant of method you could write in Apex
  • apex-mocks-generator has not been tested against all possible variations of interface method definitions – it is possible it may fail when generating a mock class for some methods – if that happens please contact me. (Or if you are very brave edit the generated mock code directly.)

Please contact me @comic96 on Twitter or via this blog to feedback or ask questions. Or fork the GitHub repo. Thank you!

Advertisements

6 thoughts on “ApexMocks Supported Features

    • There are full examples of all supported features in the fflib_ApexMocksTest class – these are the unit tests for the framework itself – using fflib_MyList as a ‘dummy’ component we would like to mock/stub. These unit tests fully illustrate all supported features.

      So I kind of thought the unit tests would speak for themselves, but I could create more code samples too if that would help.

  1. Pingback: Counters in Apex Mocks verifications – XoNoX Force

  2. Pingback: Verify call’s order in Apex unit tests – XoNoX Force

  3. Pingback: Answering with Apex Mocks – XoNoX Force

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s