Write an integration test
Updated
Every business scenario of a model gets an integration test. Tests run on the server against the live metamodel.
Note
The runner executes each case inside a transaction that is never committed. Everything the test created — rows, documents, movements — rolls back. Do not write manual cleanup. Do not depend on data another test left behind. Create what the scenario needs, at the start.
How to#
A pair Tests/<Name>.json + Tests/<Name>.cs. groupName is required —
without it the test only appears under "All tests". Group by accounting
contour, not by module — the Model column already shows the module. Copy
groupName from an existing test of the same contour. A parallel English
name would split the tree.
class ApproveOrderTests : IntegrationTestScriptBase
{
[IntegrationTest("Approve an order writes no debt")]
public async Task Approve_writes_no_debt()
{
// create customer, item, order in this method
// assert
}
}
The export owns the file name. A colon in name is fine; it cannot live
in a file name. After the first apply, re-read the folder and drop your
copy if the export wrote a canonical neighbour. Two files, one metaId, one
public partial class — the next git add -A commits a duplicate.
Db.SavepointAsync / RollbackToSavepointAsync are mid-case. Metadata the
test created (CreateDictionaryAsync, SyncSchemaAsync) can survive rollback
— use that only when the test is about metadata, and
CascadeDeleteMetadataAsync at the end.
A command is tested through FindCommandIdAsync +
ExecuteDocumentCommandAsync (or ExecuteDictionaryCommandAsync).
FindCommandIdAsync throws when the command is missing, so a test of the
button cannot pass while the button does not exist.
Tip
A test of a posting side effect (GL, tax, cost) must create the balance with a receipt document, not
PostMovementAsync("Stock"). Direct movements do not start the costing driver. The test stays green, production doubles the book.
Bump modelVersion — a test is a model object.
What's not there yet#
UI regression and Playwright shots are a different pipeline. This cookbook is the in-process integration test.