al-test-generation
Guide for creating AL tests for Microsoft Dynamics 365 Business Central. Use this when asked to write, create, or generate AL test codeunits, test procedures, or test automation for Business Central.
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 61
- Forks
- 33
01 前言 Front Matter
- name
- al-test-generation
- description
- Guide for creating AL tests for Microsoft Dynamics 365 Business Central. Use this when asked to write, create, or generate AL test codeunits, test procedures, or test automation for Business Central.
02 资源文件 2
- 资产文件assets/prices_pl.json309 B
- 资产文件assets/prices_us.json308 B
03 SKILL.md 正文
To create AL tests for Microsoft Dynamics 365 Business Central, follow this process:
1. Analyze the Code Under Test
Before writing any test code:
- Read and understand the procedure or functionality being tested
- Trace through all code paths to identify UI interactions
- Examine table definitions for TableRelation constraints
2. Identify Required Handler Methods
CRITICAL: Tests fail with "Unhandled UI" errors when handlers are missing.
Look for these patterns in the code under test:
| Code Pattern | Required Handler |
|---|---|
Confirm() |
[ConfirmHandler] |
Message() |
[MessageHandler] |
StrMenu() |
[StrMenuHandler] |
Page.Run() |
[PageHandler] |
Page.RunModal() |
[ModalPageHandler] |
Report.Run() or Report.RunModal() |
[ReportHandler] |
| Report request page | [RequestPageHandler] |
Hyperlink() |
[HyperlinkHandler] |
Notification.Send() |
[SendNotificationHandler] |
3. Analyze TableRelation Constraints
CRITICAL: Tests fail with validation errors when inserting data that violates TableRelation constraints.
Before inserting test data:
- Read the table definition for all fields receiving values
- Identify fields with
TableRelationproperties - Ensure related records exist before inserting test data
- Use Library functions (e.g.,
LibrarySales,LibraryPurchase) to create prerequisite data
4. Write Test Structure
Follow the AAA pattern (Arrange-Act-Assert):
[Test]
[HandlerFunctions('RequiredHandlers')]
procedure TestProcedureName()
begin
// [GIVEN] Setup test data and preconditions
Initialize();
CreateTestData();
// [WHEN] Execute the action being tested
ExecuteAction();
// [THEN] Verify the expected results
VerifyResults();
end;
5. Handler Method Signatures
[ConfirmHandler]
procedure ConfirmHandlerYes(Question: Text[1024]; var Reply: Boolean)
begin
Reply := true;
end;
[MessageHandler]
procedure MessageHandler(Message: Text[1024])
begin
// Empty - suppresses message display
end;
[ModalPageHandler]
procedure ModalPageHandler(var TestPage: TestPage "Page Name")
begin
TestPage.OK().Invoke();
end;
6. Best Practices
- Use descriptive test procedure names that explain what is being tested
- One assertion concept per test
- Use Library Variable Storage to pass data between handlers and tests
- Do NOT verify values inside handler procedures
- Clean up test data in teardown or use transaction rollback
- Use
Initialize()procedure to set up common test fixtures
04 同仓库更多 Skills
bcbench-example
BC-Bench example skill — a no-op skill that only exists to prove the BC-Bench `plugins` experiment toggle loaded a plugin and made its skill available. USE FOR nothing real; it is a smoke-test marker. DO NOT USE FOR actual Business Central / AL work.
extensibility-request-implement
Implement a single Business Central extensibility request as an AL code change. The request is provided as plain text (a natural-language description of the extension point that is needed, usually a new integration event / event publisher). The skill locates the affected AL code in the current repository, adds the requested extension point following the repository extensibility guidelines, and propagates the change across the W1 base layer and any same-named country/region layer files. It edits only `.al` source files and leaves the changes unstaged in the working tree. No build, no tests, no commit, and no pull request. TRIGGER when the user asks to implement or add an extensibility request / extension point / integration event described in the provided text. DO NOT TRIGGER for bug fixes, for building or testing, or for opening pull requests.
bc-ext-advisor
Guide a Business Central user through preparing a high-quality extensibility request and filing it as a GitHub issue in microsoft/ALAppExtensions. The skill classifies the request (event, external access, enum, or general enhancement), gathers the mandatory information for that type, checks it against the extensibility rules and blockers, drafts the issue against the standard template, and — only after explicit approval — submits it with the `gh` CLI. It is advisory and read-only against workspace code: it never edits, builds, or runs AL source. It applies only to Microsoft base-application AL objects. Runs interactively in VS Code Copilot Chat (agent mode) and the Copilot CLI. TRIGGER when a user wants to request an event, make a member public/global, add or extend an enum, or otherwise ask Microsoft to make base Business Central code more extensible. DO NOT TRIGGER for pure bug reports, for changes to non-Microsoft (custom) objects, or to write or fix AL code.
al-test-generation
Guide for creating AL tests for Microsoft Dynamics 365 Business Central. Use this when asked to write, create, or generate AL test codeunits, test procedures, or test automation for Business Central.
bc-al-query-mcp
Use when: writing, fixing, validating, or running Business Central AL query objects with bc_data MCP tools (and, optionally, Microsoft Learn MCP docs). Covers AL query syntax, table discovery, schemas, relations, joins, filters, FlowFields, pagination, and read-only data retrieval.
update-agent-harness
Update an agent harness used by BC-Bench. Use when bumping GitHub Copilot CLI or Claude Code, reviewing intervening release notes and breaking changes, curating benchmark-worthy model choices, updating the BC-Bench version, or preparing the release handoff.