How to do unit testing on Squidex?

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [ :white_check_mark:] Documentation issue or request

What is the general way to develop and run unit testing for a C# App using Squidex as DB?

Can we create an environment with all the schema but empty content, for the test?

Is it possible to create a snapshot before each test, and restore the backup after the test run?

Environment

App Name: middle-stage-phone-pk

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ :white_check_mark:] Cloud version

Version: Init

Browser: [Doesn’t matter]

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Hi,

It is independent from the programming language.

the main question is: Do you want to do unit testing or integration testing?

Unit testing

To make unit testing easier, Squidex provides interfaces for all clients and the client manager: https://github.com/Squidex/squidex-samples/blob/master/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ISquidexClientManager.cs

You can use this to mock these services, e.g. with FakeItEasy: https://fakeiteasy.github.io/

Integration testing

Usually for integration testing you should have a separate environment. You can either use the CLI and the sync command to create a plain app that you use for starting everything or you do it manually: https://docs.squidex.io/02-documentation/developer-guides/automation-tools#synchronize-all-app-settings-beta

It would be better, if you do this with self hosted instance inside your CI, so we can easily get rid of the chunk data, e.g. in the github CI I start a docker-compose with all my dependencies and use this to run a few hundred tests on that: https://github.com/Squidex/squidex/actions

Hello, thanks a lot for the elaboration. I am going to try out these options.