Custom-laget bestaar nu begge CI-checks: 72 validator-fejl -> 0

Normalisering af alle 39 custom knowledge-filer til READ-kontraktens
skema (validate_frontmatter.py + Test-KnowledgeIndex.ps1 begge groenne):

- R01/R02: 28 filer manglede frontmatter eller brugte aeldre skemaer
  (title/category/severity/rule-id m.fl.) - alle har nu praecis de 6
  kraevede noegler; keywords haandskrevet pr. fil da de driver
  worklist-selektionen i INDEX/knowledge-index
- R09: manglende Description-sektion - regel-agtige foersteoverskrifter
  (Core Rule/Rule/Regel/Core Principle) omdoebt, eller sektion indsat
  efter titlen hvor intro-tekst fandtes
- R10: fenced code blocks konverteret til 4-space indrykkede blokke
  i alle filer (indhold uaendret)
- R11: 4 filer over 100 linjer fortaettet redaktionelt uden semantisk
  tab (ai-eval-scores 143->100, git-lifecycle 121->97,
  permission-sets 113->99, test-feature-scenario-tags 105->91)
- R05: AL0197->al0197, add_repo->add-repo; keyword-lister trimmet
  til maks 10

Ingen regler er fjernet eller aendret i betydning - kun form.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Michael Dieringer 2026-07-01 23:47:31 +02:00
parent ec2892f0ab
commit dd5637b1db
39 changed files with 729 additions and 814 deletions

View file

@ -1,6 +1,14 @@
---
bc-version: [all]
domain: testing
keywords: [bcpt, performance-test, scenarios, app-specific]
technologies: [al]
countries: [w1]
application-area: [all]
---
# CURABIS Testing: BCPT Scenarios Must Be App-Specific
## Core Rule
## Description
A PerformanceTest app must include BCPT scenario codeunits that exercise the **host app's own business flows** — not only the generic Microsoft scenarios (sales orders, purchase orders, GL entries). Generic scenarios measure BC's baseline performance; app-specific scenarios are the only way to detect performance regressions in the extension's own code.
@ -19,51 +27,49 @@ For every major business flow in the host app, create a corresponding `BCPT*` co
## Example: Project Management App
```al
codeunit 80100 "BCPT Create Project" implements "BCPT Test Param. Provider"
{
SingleInstance = true;
codeunit 80100 "BCPT Create Project" implements "BCPT Test Param. Provider"
{
SingleInstance = true;
trigger OnRun()
begin
if not IsInitialized then begin
InitTest();
IsInitialized := true;
trigger OnRun()
begin
if not IsInitialized then begin
InitTest();
IsInitialized := true;
end;
CreateProject(GlobalBCPTTestContext);
end;
CreateProject(GlobalBCPTTestContext);
end;
var
GlobalBCPTTestContext: Codeunit "BCPT Test Context";
IsInitialized: Boolean;
var
GlobalBCPTTestContext: Codeunit "BCPT Test Context";
IsInitialized: Boolean;
local procedure InitTest()
begin
// Set up any required BC configuration
end;
local procedure InitTest()
begin
// Set up any required BC configuration
end;
local procedure CreateProject(var BCPTTestContext: Codeunit "BCPT Test Context")
begin
BCPTTestContext.StartScenario('Create Project Header');
// ... create project
BCPTTestContext.EndScenario('Create Project Header');
BCPTTestContext.UserWait();
local procedure CreateProject(var BCPTTestContext: Codeunit "BCPT Test Context")
begin
BCPTTestContext.StartScenario('Create Project Header');
// ... create project
BCPTTestContext.EndScenario('Create Project Header');
BCPTTestContext.UserWait();
BCPTTestContext.StartScenario('Add Project Task');
// ... add task
BCPTTestContext.EndScenario('Add Project Task');
end;
BCPTTestContext.StartScenario('Add Project Task');
// ... add task
BCPTTestContext.EndScenario('Add Project Task');
end;
procedure GetDefaultParameters(): Text[1000]
begin
exit('');
end;
procedure GetDefaultParameters(): Text[1000]
begin
exit('');
end;
procedure ValidateParameters(Parameters: Text[1000])
begin
end;
}
```
procedure ValidateParameters(Parameters: Text[1000])
begin
end;
}
## Suggested Scenarios for Project Management Apps

View file

@ -1,6 +1,14 @@
---
bc-version: [all]
domain: testing
keywords: [testing, test-data, random, library, any]
technologies: [al]
countries: [w1]
application-area: [all]
---
# CURABIS Test Data Guidelines
## Core Principle
## Description
"CURABIS tests assume an empty database. All test data must be created programmatically — never assume existing records or hardcode codes, numbers, or names that may or may not exist in a given environment."

View file

@ -1,7 +1,7 @@
---
bc-version: [all]
domain: testing
keywords: [test, feature, scenario, given, when, then, tags, bdd, atdd, comments, structure]
keywords: [test, feature, scenario, given, when, then, tags, bdd, atdd, comments]
technologies: [al]
countries: [w1]
application-area: [all]
@ -31,69 +31,52 @@ what is covered without reading AL.
## Anti Pattern
```al
// WRONG: no structure — tests as anonymous procedures
codeunit 99006 "Find Price Testing"
{
Subtype = Test;
// WRONG: no structure — tests as anonymous procedures
codeunit 99006 "Find Price Testing"
{
Subtype = Test;
[Test]
procedure Test1() // what does this test?
begin
// setup mixed with assertions, no clear layers
Customer.Insert(false);
FindPriceMgt.GetSalesPrice(Customer."No.", Item."No.", '', Price, Disc);
Assert.AreEqual(100, Price, '');
end;
}
```
[Test]
procedure Test1() // what does this test?
begin
// setup mixed with assertions, no clear layers
Customer.Insert(false);
FindPriceMgt.GetSalesPrice(Customer."No.", Item."No.", '', Price, Disc);
Assert.AreEqual(100, Price, '');
end;
}
## Best Practice
```al
// [FEATURE] Find Price — price cascade (Customer → Price Group → All Customers)
codeunit 99006 "Find Price Testing"
{
Subtype = Test;
// [FEATURE] Find Price — price cascade (Customer → Price Group → All Customers)
codeunit 99006 "Find Price Testing"
{
Subtype = Test;
var
WarecoLib: Codeunit "Wareco Test Library";
Assert: Codeunit "Library Assert";
var
WarecoLib: Codeunit "Wareco Test Library";
Assert: Codeunit "Library Assert";
// [SCENARIO] Customer with a specific price list line gets that unit price
[Test]
procedure GetPrice_CustomerPrice_ReturnsUnitPrice()
var
Customer: Record Customer;
Item: Record Item;
UnitPrice, LineDiscPct: Decimal;
begin
// [GIVEN] a customer with a price list line at 100 LCY
WarecoLib.GivenCustomerWithPrice(Customer, Item, '', 100);
// [WHEN]
FindPriceMgt.GetSalesPrice(Customer."No.", Item."No.", '', UnitPrice, LineDiscPct);
// [THEN]
Assert.AreEqual(100, UnitPrice, 'Unit price must match customer price list');
end;
// [SCENARIO] Customer with a specific price list line gets that unit price
[Test]
procedure GetPrice_CustomerPrice_ReturnsUnitPrice()
var
Customer: Record Customer;
Item: Record Item;
UnitPrice, LineDiscPct: Decimal;
begin
// [GIVEN] a customer with a price list line at 100 LCY
WarecoLib.GivenCustomerWithPrice(Customer, Item, '', 100);
// [WHEN]
FindPriceMgt.GetSalesPrice(Customer."No.", Item."No.", '', UnitPrice, LineDiscPct);
// [THEN]
Assert.AreEqual(100, UnitPrice, 'Unit price must match customer price list');
end;
}
// [SCENARIO] Customer with no price list line falls back to item unit price
[Test]
procedure GetPrice_NoCustomerPrice_FallsBackToItemPrice()
var
Customer: Record Customer;
Item: Record Item;
UnitPrice, LineDiscPct: Decimal;
begin
// [GIVEN] a customer with no price list, item priced at 200
WarecoLib.GivenCustomer(Customer);
WarecoLib.GivenItem(Item, 200);
// [WHEN]
FindPriceMgt.GetSalesPrice(Customer."No.", Item."No.", '', UnitPrice, LineDiscPct);
// [THEN]
Assert.AreEqual(200, UnitPrice, 'Must fall back to item unit price');
end;
}
```
Every further `[Test]` procedure in the codeunit repeats the same pattern: its
own `[SCENARIO]` comment above the attribute, and `[GIVEN]`/`[WHEN]`/`[THEN]`
layers inside the body.
## Relationship to procedure naming

View file

@ -25,55 +25,51 @@ belongs in `[WHEN]`.
## Anti Pattern
```al
// WRONG: two actions in one test
[Test]
procedure GetPrice_ThenGetDiscount_ReturnsCorrectValues()
var
UnitPrice, LineDiscPct: Decimal;
begin
// [GIVEN] ...
// [WHEN] first action
FindPriceMgt.GetSalesPrice(CustomerNo, ItemNo, '', UnitPrice, LineDiscPct);
// [WHEN] second action — this is a second test in disguise
FindPriceMgt.GetSalesPriceTiers(CustomerNo, ItemNo, '', TempBuffer);
// [THEN] asserting two unrelated things
Assert.AreEqual(100, UnitPrice, '');
Assert.IsFalse(TempBuffer.IsEmpty(), '');
end;
```
// WRONG: two actions in one test
[Test]
procedure GetPrice_ThenGetDiscount_ReturnsCorrectValues()
var
UnitPrice, LineDiscPct: Decimal;
begin
// [GIVEN] ...
// [WHEN] first action
FindPriceMgt.GetSalesPrice(CustomerNo, ItemNo, '', UnitPrice, LineDiscPct);
// [WHEN] second action — this is a second test in disguise
FindPriceMgt.GetSalesPriceTiers(CustomerNo, ItemNo, '', TempBuffer);
// [THEN] asserting two unrelated things
Assert.AreEqual(100, UnitPrice, '');
Assert.IsFalse(TempBuffer.IsEmpty(), '');
end;
## Best Practice
```al
// CORRECT: split into two focused tests
// CORRECT: split into two focused tests
[Test]
procedure GetPrice_CustomerPrice_ReturnsCorrectUnitPrice()
var
UnitPrice, LineDiscPct: Decimal;
begin
// [GIVEN] a customer with a price list line at 100
WarecoLib.GivenCustomerWithPrice(Customer, Item, '', 100);
// [WHEN]
FindPriceMgt.GetSalesPrice(Customer."No.", Item."No.", '', UnitPrice, LineDiscPct);
// [THEN]
Assert.AreEqual(100, UnitPrice, 'Unit price must match price list');
end;
[Test]
procedure GetPrice_CustomerPrice_ReturnsCorrectUnitPrice()
var
UnitPrice, LineDiscPct: Decimal;
begin
// [GIVEN] a customer with a price list line at 100
WarecoLib.GivenCustomerWithPrice(Customer, Item, '', 100);
// [WHEN]
FindPriceMgt.GetSalesPrice(Customer."No.", Item."No.", '', UnitPrice, LineDiscPct);
// [THEN]
Assert.AreEqual(100, UnitPrice, 'Unit price must match price list');
end;
[Test]
procedure GetPriceTiers_CustomerTier_ReturnsOneTierLine()
var
TempBuffer: Record "Find Price Tier Buffer" temporary;
begin
// [GIVEN] a customer with a tier price at min qty 10
WarecoLib.GivenCustomerWithTierPrice(Customer, Item, '', 10, 90);
// [WHEN]
FindPriceMgt.GetSalesPriceTiers(Customer."No.", Item."No.", '', TempBuffer);
// [THEN]
Assert.AreEqual(1, TempBuffer.Count(), 'Exactly one tier line expected');
end;
```
[Test]
procedure GetPriceTiers_CustomerTier_ReturnsOneTierLine()
var
TempBuffer: Record "Find Price Tier Buffer" temporary;
begin
// [GIVEN] a customer with a tier price at min qty 10
WarecoLib.GivenCustomerWithTierPrice(Customer, Item, '', 10, 90);
// [WHEN]
FindPriceMgt.GetSalesPriceTiers(Customer."No.", Item."No.", '', TempBuffer);
// [THEN]
Assert.AreEqual(1, TempBuffer.Count(), 'Exactly one tier line expected');
end;
## Naming implication

View file

@ -1,6 +1,14 @@
---
bc-version: [all]
domain: testing
keywords: [testing, test-setup, library-codeunit, initialization]
technologies: [al]
countries: [w1]
application-area: [all]
---
# CURABIS Test Library Standards
## Core Rules
## Description
The documentation establishes three critical testing practices for CURABIS AL applications:

View file

@ -32,37 +32,31 @@ Writing a test that adapts to existing code is **not** the same as writing a
test that accepts wrong behaviour silently. If the production code contains a
bug that contradicts the business specification, flag it explicitly:
```
// ⚠️ NOTE: This assertion reflects current code behaviour.
// Business spec says 1792,00 but code currently produces 1800,00.
// Flagged for review — do not merge until resolved.
```
// ⚠️ NOTE: This assertion reflects current code behaviour.
// Business spec says 1792,00 but code currently produces 1800,00.
// Flagged for review — do not merge until resolved.
Never silently adjust an assertion to make a test green when the discrepancy
is a real business logic error.
## Anti Pattern
```al
// WRONG: Writing the "ideal" test without reading the production code,
// then leaving it failing and saying "the code needs to be fixed"
[THEN]
Assert.AreEqual(1792, ActualAmount, 'Total should be 1792');
// Test fails. Agent says: "You need to fix SVPost to produce 1792."
// This is not what was asked for.
```
// WRONG: Writing the "ideal" test without reading the production code,
// then leaving it failing and saying "the code needs to be fixed"
[THEN]
Assert.AreEqual(1792, ActualAmount, 'Total should be 1792');
// Test fails. Agent says: "You need to fix SVPost to produce 1792."
// This is not what was asked for.
## Best Practice
```al
// CORRECT: Read SVPost, understand what it produces, write the test to match.
// If the number is 1792 in both spec and code → assert 1792.
// If the number differs → flag it, don't silently change it.
// CORRECT: Read SVPost, understand what it produces, write the test to match.
// If the number is 1792 in both spec and code → assert 1792.
// If the number differs → flag it, don't silently change it.
// [GIVEN] Read SVPost.Codeunit.al and SV Test Library before writing assertions.
// [THEN] Assert what the code actually produces, verified by reading the source.
Assert.AreEqual(ExpectedAmount, ActualAmount, 'Net payout to vendor must match');
```
// [GIVEN] Read SVPost.Codeunit.al and SV Test Library before writing assertions.
// [THEN] Assert what the code actually produces, verified by reading the source.
Assert.AreEqual(ExpectedAmount, ActualAmount, 'Net payout to vendor must match');
## Workflow when asked to write a passing test

View file

@ -30,71 +30,65 @@ in the same codeunit.
## Anti Pattern
```al
// WRONG: UI test codeunit without _UT suffix
codeunit 99007 "Find Price Page Testing"
{
Subtype = Test;
// contains TestPage calls — should be named "Find Price Testing_UT"
...
}
```
```al
// WRONG: mixing direct codeunit calls and TestPage calls in the same codeunit
codeunit 99007 "Find Price Testing"
{
Subtype = Test;
[Test]
procedure GetPrice_LogicTest() // logic test — fine here
begin
FindPriceMgt.GetSalesPrice(...);
end;
[Test]
procedure Page_ShowsPrice_UT() // UI test — belongs in separate _UT codeunit
var
FindPricePage: TestPage "Find Price";
begin
FindPricePage.OpenNew();
// WRONG: UI test codeunit without _UT suffix
codeunit 99007 "Find Price Page Testing"
{
Subtype = Test;
// contains TestPage calls — should be named "Find Price Testing_UT"
...
end;
}
```
}
// WRONG: mixing direct codeunit calls and TestPage calls in the same codeunit
codeunit 99007 "Find Price Testing"
{
Subtype = Test;
[Test]
procedure GetPrice_LogicTest() // logic test — fine here
begin
FindPriceMgt.GetSalesPrice(...);
end;
[Test]
procedure Page_ShowsPrice_UT() // UI test — belongs in separate _UT codeunit
var
FindPricePage: TestPage "Find Price";
begin
FindPricePage.OpenNew();
...
end;
}
## Best Practice
```al
// CORRECT: separate codeunits per layer
// CORRECT: separate codeunits per layer
// Logic tests — no _UT suffix
codeunit 99006 "Find Price Testing"
{
Subtype = Test;
[Test]
procedure GetPrice_CustomerPrice_ReturnsUnitPrice()
begin
FindPriceMgt.GetSalesPrice(...);
end;
}
// Logic tests — no _UT suffix
codeunit 99006 "Find Price Testing"
{
Subtype = Test;
[Test]
procedure GetPrice_CustomerPrice_ReturnsUnitPrice()
begin
FindPriceMgt.GetSalesPrice(...);
end;
}
// UI tests — _UT suffix
codeunit 99007 "Find Price Testing_UT"
{
Subtype = Test;
[Test]
procedure Page_EnterCustomerAndItem_FactBoxShowsPrice()
var
FindPricePage: TestPage "Find Price";
begin
FindPricePage.OpenNew();
FindPricePage.CustomerNo.SetValue(Customer."No.");
FindPricePage.ItemNo.SetValue(Item."No.");
Assert.AreEqual('100,00', FindPricePage.FindPriceInfo.UnitPrice.Value(), '');
end;
}
```
// UI tests — _UT suffix
codeunit 99007 "Find Price Testing_UT"
{
Subtype = Test;
[Test]
procedure Page_EnterCustomerAndItem_FactBoxShowsPrice()
var
FindPricePage: TestPage "Find Price";
begin
FindPricePage.OpenNew();
FindPricePage.CustomerNo.SetValue(Customer."No.");
FindPricePage.ItemNo.SetValue(Item."No.");
Assert.AreEqual('100,00', FindPricePage.FindPriceInfo.UnitPrice.Value(), '');
end;
}
## Object ID allocation