Testing

Mocking JSforce with Jest

by Patrick Connelly posted on March 30, 2021

Testing is one of the most important things you can do your code. However, when using a library that requires access to a remote system unit testing can become problematic. You don’t want to have to have a real connection and pull down real data since this is slow and requires anyone contributing to your project to set up the remote system as well. This is where mocking comes in with Jest.

Mocking allows you to detach a module from making a remote call and allows you to define the data that it returns. This means that you can modify the data how you need to provide a small data set or a large data set or even error out on demand.

In this post, we’re going to look at how to set up mocking for JSforce to test logging in and mocking out making queries.


JMeter – Logging Into Salesforce for Automated Testing

by Patrick Connelly posted on June 29, 2017

I’ve written quite a few web services in Salesforce, and I’ve written about them a couple of times. And my love of testing is pretty well known. One thing that’s always been a problem is testing the web services in an automated fashion as a real consumer would. I’ve talked about manually testing them with SoapUI before, and while useful doesn’t fit into an automated process well. So let’s jump into the world of JMeter and how we can automate our web service testing for Salesforce.


Testing NOW in Apex

by Patrick Connelly posted on March 21, 2016

If you’ve ever written a trigger that stores Date.now(), then this scene from Spaceballs may seem very familiar. This is how I feel when testing now.

Testing now

  • Dark Helmet: What the hell am I looking at? When does this happen in the movie?
  • Colonel Sandurz: Now. You’re looking at now, sir. Everything that happens now, is happening now.
  • Dark Helmet: What happened to then?
  • Colonel Sandurz: We passed then.
  • Dark Helmet: When?
  • Colonel Sandurz: Just now. We’re at now now.
  • Dark Helmet: Go back to then.
  • Colonel Sandurz: When?
  • Dark Helmet: Now.
  • Colonel Sandurz: Now
  • Dark Helmet: Now.

The problem comes down to knowing when now is. Obviously, now is something that’s in constant flux and will change throughout your test. But there are ways to be able to know when now really is in your test.