function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ZoomzoomZoomzoom 

Bringing functional specs closer to the code

One of my interests lately has been to bring the functional specs closer to the apex code, make it easier for users to know what is actually been implemented. Yes, there should be a documentation, but in my experience it can quickly go out of sync after several iterative changes in the code. Also, sometimes the wording is key. "Record types A and B" can be the same than "Every record type but C and D", but it may not in the future.

 

Here are some things I've been working on. Let me know if you have suggestions:

 

  • When fields values are computed by some apex code, I use the fields' inline help to store the description of how they are computed. It's not a perfect solution because one needs to change those on top of deploying code. But this allows to put these definitions readily available for users, as well as display these them inside a VF page if need be.
  • Expanding on the previous concept, for some fields I used the inline help to define my own formulas, like computing the time between a case was first opened and the time the status was last set to a given value. An apex scheduled job computes the value every night.
  • In order to test a custom apex+VF scorecard which computes all sorts of metrics out of Cases, I have defined a series of tests comprised of 1) test input cases which will be fed to the scorecard and 2) several scenarios detailing the user filters and expected output. The same code that generate this test input and expected output (in the form of objects) is used for both the apex test and a VF page which displays them, allowing us to check it is computing what it's supposed to.
  • I recently discovered Ruby's cucumber, which is testing some code by parsing a description in plain English ("Given I have entered 'foo' in the field and I press 'create' then I should see the record 'foo' on the list"). I was wondering if anybody has written a similar tool in apex.

Thanks,

Laurent