Test environment
Table of contents
Introduction
Tests run inside your product’s web container, against a database of their own, and never against production. feature:test takes care of all of it.
splent product:up --dev
splent feature:test
Run from the CLI container, feature:test re-runs itself in <product>_web, where the features and pytest are installed, and stops if that container is not running.
How the test app is built
The fixtures call create_app("testing"), which loads TestingConfig.
class TestingConfig(Config):
TESTING = True
WTF_CSRF_ENABLED = False
def __init__(self):
super().__init__()
self.SQLALCHEMY_DATABASE_URI = _build_db_uri(
"MARIADB_TEST_DATABASE", "default_test_db"
)
Before running, feature:test checks that the database name contains test and differs from MARIADB_DATABASE.
Refusing production
Tests refuse to run when SPLENT_ENV=prod is set in the tests’ environment, in the product’s docker/.env (quoted or exported, any case), or in the running web container.
❌ Cannot run tests in production.
A production deployment is active.
Stop the deployment and start dev:
splent product:deploy --down
splent product:derive --dev
Reference
Database variables
| Variable | Default | Purpose |
|---|---|---|
MARIADB_USER, MARIADB_PASSWORD |
default_user, default_password |
Credentials |
MARIADB_HOSTNAME, MARIADB_PORT |
localhost, 3306 |
Server |
MARIADB_TEST_DATABASE |
default_test_db |
The test database |
E2E and load variables
| Variable | Default | Purpose |
|---|---|---|
SELENIUM_GRID_URL |
Unset | Attach to this grid instead of a local browser |
SELENIUM_BROWSER |
chrome |
chrome or firefox |
SELENIUM_TARGET_URL |
Unset | The base URL. Required with a grid |
SPLENT_LOCUSTFILES |
Unset | Comma-separated globs that replace locustfile discovery |
See E2E (Selenium) and Load (Locust).
See also
- Fixtures, the fixtures that build the app and reset the database