Support Topics Documentation Slack YouTube Blog

Writing integration tests on server code

How would one create an integration test that tests services and handlers? Is it recommended to use Coderunner on a CI or is there a better way? If Coderunner is the recommended way, is there an example somewhere that shows how to do it? Since the process doesn’t exit, how would you figure out when to start running the tests?

Hi,

you can try to clone an existing app, deploy handlers to the production mode, and so that the tests communicate with the “test” copy of the application. A cloned app would be nice for tests didn’t affect production backend.

Unfortunately, we have no examples of such testing. But perhaps in the near future it will appear.

Regards,
Stanislaw

Is it possible to programmatically empty the cloned application to run tests every time on a fresh environment? There is also the restriction on size of server code - how can we test our server code if it’s getting blocked with “Your application has exceeded a limit of the Business Logic deployment size on the current plan. All API calls will be blocked within 48 hours after the limit is exceeded.”?

You can use the Reset App REST API which is used by Backendless Console (see the “Reset App” button on the main dashboard). Your code would need to login as a Backendless developer, get the auth-token and then send the reset app call using the token.

As for the Business Logic limit (or any other limit for that matter) if the application is blocked, it will start rejecting all calls. Consider reducing the NPM dependencies by installing only modules you need. See this for more details: https://backendless.com/docs/bl-js/bl_node_modules.html

Regards,
Mark

Thanks Mark. This seems to be the biggest blocker - it seems like there isn’t a way for me to get my dependencies down to that size. The other issue is that creating a sandbox project to run integration tests has the same issue. I’m happy to pay once the app is in production but I can’t even develop my app to make it production-ready with these blockers.

If the app is reset and then cloud code is deployed, will the block be lifted? That could work for the sandbox app.

Hi @Garrett_Gottlieb

There is an NPM package for working with Backendless Console’s API https://github.com/Backendless/Console-SDK, it’s not documented but I believe you will figure out how it works

In theory you can setup your own environment which may work by the following scenario

  1. login as developer with ConsoleSDK (using your login/password for Console)
  2. create/clone a new Backendless App
  3. deploy BL into the app
  4. do some tests
  5. remove the test app

Regards, Vlad