Running tests¶
Python tests in a Lime CRM solution or package run with pytest and lime-test, our own pytest plugin. Code generated with lime-project generate includes boilerplate tests where you can add your own.
Web components are tested with a different toolchain — see Testing in the web client.
Info
Our standard CI toolchain will fail any build containing any test error.
Which kinds of Python tests are there?¶
A project can have two kinds of Python tests. They live in different folders and run with different commands.
| Unit tests | Integration tests | |
|---|---|---|
| Folder | tests/ |
integration_tests/ |
| Database | In-memory database, fresh for every test | SQL Server |
| Command | poetry run pytest |
poetry run pytest integration_tests --load-lime-test-integration-plugin |
| Local requirements | None beyond the project's dependencies | Docker and the Microsoft ODBC Driver 18 for SQL Server |
Every project has unit tests. Integration tests are optional: lime-project does not create the integration_tests/ folder, and a project without it is complete.
How to run unit tests¶
Run all unit tests from the root of the project:
VS Code can be configured to discover and run the tests.
To learn how to write them, see Writing tests.
How to run integration tests¶
Run the integration tests from the root of the project, with Docker running:
With the option, the tests run against SQL Server instead of the in-memory database. See Integration tests for the folder setup, the local requirements, and how these tests differ from unit tests.
Fixtures¶
lime-test ships a large set of ready-made fixtures — see the Fixtures section for an overview, the conventions they follow, and a per-fixture reference.
Related pages¶
- Writing tests introduces
lime-testand shows how to test business logic and endpoints. - Integration tests explains how to test against a real SQL Server.
- Testing best practices collects the practices we recommend, including how to replace dependencies in a test.
- Migrating tests to the new fixtures explains how to move a project off the deprecated fixtures.