Most code is full of bugs. Some estimates suggest that every 20 lines of code will contain a serious bug. What can we do about it? One technique that's proven to reduce bug density is test driven development. By writing unit tests to prove that our code does what it's meant to do, we reduce the likelihood that bugs will creep in.
But how can we write unit tests for Zoho Creator apps? There's no inbuilt testing framework. We could use Selenium to write UI tests but they're slow and laborious to write and maintain.
As an alternative, I propose using HTML pages as unit testing harnesses. Here's an example of a unit test I set up to test some advanced trigonometric functions I added to my app so I could calculate distance using the great circular distance method. Deluge doesn't come with arctan/msatan out of the box, so I had to add those in. Here's an example of what I did to ensure that the functions gave the correct result.
Here's the code to achieve that result:
Let me know what you think. Would be cool if we could get a proper unit testing framework built into the framework but for now, this will have to do.
Comments
Post a Comment