βœ…Regression Testing

Write Module Tests

Devin's testing feature allows you to run specific test scripts from your file's script workspace. This is useful to ensure that certain "units" or "integrations" work as expected before publishing the changed file to production. The term "unit" relates to testing specific logic or a certain component of your code. "Integration" referes to testing external dependencies, such as a connection to an API.

In your file’s script workspace, create a folder for your tests. By default, Devin will look for a Tests folder, but you can specify a custom name in Project Settings. Devin will interpret all scripts in this folder as test scripts.

In your test scripts, use Exit Script [True] to indicate when a test is succesful. Otherwise, the test will fail.

Load, run and monitor your test runs in the Modules -> Tests tab.

It is best practice to have have many simple tests that ideally only test a single unit or integration of your code. For example, for an app that fetches data via an external API, you could write a test for each of the expected responses that you expect this API to return. Say that given some valid parameters, it should return a status code of 200. Then, in your test script, you save the API's response code in a variable $status_code and check that if $status_code = 200 , Exit Script [True].

Devin runs your tests via the FM OData API. Make sure that the file's credentials have the odata extended privileges enabled and beware that the OData API does not support scripts names that start with numbers or contain special characters.

Last updated