Hi Ben, I recently started following these guidelines for test-driven development so the development starts in Anvil with the creation of the app, then it’s 100% on PyCharm until I’m sure all the logic works well and it’s covered by tests, then it’s back online in the Anvil IDE for the UI. This last step is very fast, because the classes are UI-ready and there is no need to create any helper that returns dictionaries for the repeating panels or other tedious work.
I also started using the DataGridJson, which cuts the number of forms down to less than half (when you have multiple DataGrids in many forms) and the code is better organized because all the event handlers are in the form rather than spread in the row template forms.
All the client code in Globals
is easily testable because there are no interactions with UI, database or other services. The server code is very little and almost completely tested, because it’s used by Globals
. And it’s easy to decide whether to debug it in PyCharm or to run it in the server (where it’s usually faster while interacting with the database).
I abandoned the mock databases classes because (1) I kept finding out that something was missing and (2) I was afraid (actually hoped) that Anvil would improve app_tables
and I would keep falling behind (indeed app_tables
has improved, there are the new q
operators, etc.). Now I test the exact same code that runs in production.