Testing
A Jadpo test runs your real application against a real database. Only the outside world and the clock are replaced: every call to an outside service answers from a fake, and the clock stands still until the test moves it. You don't mock your own actions, and there is no in-memory stand-in for the database.
This page covers where tests live, the kinds of test, the settings a test takes, acting as a user, controlling time, configuration and fakes in tests, shared test data, assertions, running tests, the test database, and how tests meet caches and events.
Most examples use a todo app's planning domain, the folder that holds
one business area of the app. It has User and Todo entities (kinds of
stored record), a create_todo action, a TodoNotFound failure, an
overdue_reminders schedule and a ReminderMail integration with an
outside email service.
| Where tests live A test sits beside the file it tests, in a file named |
| Writing a test A test is a sentence that names it, then a body of ordinary code. |
| Kinds of test Jadpo works out a test's kind from what it calls, so you don't declare it. |
| Test settings A test needs no settings. |
| Acting as a user An action receives its caller, the person or service signed in, as a typed parameter (The principal). |
| Controlling time A test never waits for real time. |
| Configuration in tests A test never reads your machine's environment. |
| Fakes for integrations A test never reaches a real provider, the outside service an integration talks to. |
| Shared test data: fixtures When several test files need the same data, write a fixture. |
| Assertions
|
| Running tests
|
| The test database Each test gets its own database at the latest migration, empty except for what its fixtures create. |
| Events and caches in tests An event is a fact an action records, such as "an order was placed", and a subscriber is code that runs when one is delivered (Subscribers). |
What is built says which of this works today.
Markdown for agents: /docs/testing.md.Built from Jadpo main at aee2e8f.