Skip to content

[Subcontracting] Move subcontracting tests from Base Test App to Subcontracting Test App#7740

Open
stevengrossGOB wants to merge 8 commits into
microsoft:mainfrom
GOB-Software-Systeme-DevOps:w/grosss/MoveSubcontractingWorksheetTestsToSubcApp_FomMSMain
Open

[Subcontracting] Move subcontracting tests from Base Test App to Subcontracting Test App#7740
stevengrossGOB wants to merge 8 commits into
microsoft:mainfrom
GOB-Software-Systeme-DevOps:w/grosss/MoveSubcontractingWorksheetTestsToSubcApp_FomMSMain

Conversation

@stevengrossGOB
Copy link
Copy Markdown
Contributor

@stevengrossGOB stevengrossGOB commented Apr 17, 2026

During the obsoletion process for the Subcontracting Worksheet, the corresponding tests will be removed from the Base Test App at CLEAN29. These tests will then be moved to Subcontracting Test App in order to maintain the existing test coverage.

Fixes AB#619326

- Updated references in SubcPurchSubcontTest, SubcSubcontractingSyncTest,
  and SubcSubcontractingTest codeunits for consistency.
- Improved code readability and maintainability by standardizing library naming.
@stevengrossGOB stevengrossGOB requested review from a team as code owners April 17, 2026 06:40
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Apr 17, 2026
@stevengrossGOB stevengrossGOB marked this pull request as draft April 17, 2026 06:40
@github-actions github-actions Bot added the Linked Issue is linked to a Azure Boards work item label Apr 17, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Apr 17, 2026
@ChethanT
Copy link
Copy Markdown
Contributor

ChethanT commented Apr 17, 2026

Missing test compared to W1 disabled tests

Compared all #if not CLEAN29-guarded [Test] procedures across the W1 subcontracting test files against this PR. Out of 76 disabled tests, 75 are covered — one is missing:

Source file (W1) Missing procedure Expected target codeunit
SCMWIPCostingProductionII.Codeunit.al StdSubconManCostDiff SubcSCMWIPCostingProd.Codeunit.al

Scenario: Test Standard Costing of Subcontracting Order with Flushing method - Manual. Subcontract and Output Cost different from Expected.

Parameters: UnitCostCalcType=Units, FlushingMethod=Manual, SubcontractFlushingMethod=Manual, CostingMethod=Standard, Subcontract=true, SubcontractCostDiff=true, OutputCostDiff=true

The PR includes the AddCurr variant (StdSubconManCostDiffAddCurr) and StdSubconBackward, but the plain StdSubconManCostDiff (no additional currency, subcontract + output cost diff scenario) is absent from SubcSCMWIPCostingProd.

@stevengrossGOB
Copy link
Copy Markdown
Contributor Author

@ChethanT I have added the missing test

ChethanT
ChethanT previously approved these changes Apr 20, 2026
@JesperSchulz JesperSchulz added the SCM GitHub request for SCM area label Apr 21, 2026
@stevengrossGOB
Copy link
Copy Markdown
Contributor Author

@ChethanT all countries succeeded, except the w1 unit tests. What's the reason for that? Can you help me fixing them?

@stevengrossGOB stevengrossGOB marked this pull request as ready for review April 28, 2026 11:57
@JesperSchulz
Copy link
Copy Markdown
Contributor

@ChethanT all countries succeeded, except the w1 unit tests. What's the reason for that? Can you help me fixing them?

Here's the explanation from Copilot (if it doesn't help, let's get @ChethanT onboard):

The failures in job 72151291862 are not random—there are two consistent missing-test-data problems in the Subcontracting test suite:

  1. Multiple tests fail with: “The Routing Link table is empty.”
    Stack trace points to: Subc SCM Prod. Order (CodeUnit 149916).CreateRoutingAndUpdateItemSubc line 9.

  2. Many tests fail with: “There is no Capacity Unit of Measure within the filter. Filters: Type: Minutes”
    Stack trace points to: Subc SCM Mfg. 70 (CodeUnit 149917).CreateWorkCenterSetup line 8.

Because the repository file fetch for those codeunits failed from here, I can’t quote the exact lines or propose a precise patch against the current implementation. However, the fix is straightforward and should be applied in the test setup methods indicated by the stack traces.

Fix strategy (what to change)

A) Ensure Routing Links exist before creating/validating routings

In CreateRoutingAndUpdateItemSubc (CodeUnit 149916), the test expects at least one record in Routing Link. The function currently assumes the table is pre-populated, but in isolated CI containers it’s empty.

Code suggestion (AL): add an “ensure” step at the start of CreateRoutingAndUpdateItemSubc:

local procedure EnsureRoutingLinksExist()
var
    RoutingLink: Record "Routing Link";
begin
    if not RoutingLink.IsEmpty() then
        exit;

    // Create minimal required Routing Link(s) for tests
    RoutingLink.Init();
    // Set mandatory fields as required by table validation in your app/version
    // e.g. RoutingLink.Code := 'SUBC';
    RoutingLink.Insert(true);
end;

Then call it at the top of CreateRoutingAndUpdateItemSubc:

procedure CreateRoutingAndUpdateItemSubc(...)
begin
    EnsureRoutingLinksExist();
    ...
end;

If your table requires specific fields (very likely), populate them with values your tests use. The important part is: don’t assume demo data exists.

B) Ensure a “Minutes” Capacity Unit of Measure exists before Work Center setup

In CreateWorkCenterSetup (CodeUnit 149917), the code is filtering Capacity Unit of Measure by Type = Minutes and failing because no such record exists in the test company.

Code suggestion (AL): create/get the record before filtering/using it:

local procedure EnsureCapacityUoMMinutesExists(): Code[10]
var
    CapUoM: Record "Capacity Unit of Measure";
begin
    CapUoM.SetRange(Type, CapUoM.Type::Minutes);
    if CapUoM.FindFirst() then
        exit(CapUoM.Code);

    CapUoM.Init();
    CapUoM.Code := 'MIN'; // or any unused code
    CapUoM.Type := CapUoM.Type::Minutes;
    // set other required fields if validation demands it
    CapUoM.Insert(true);

    exit(CapUoM.Code);
end;

Then in CreateWorkCenterSetup, use the returned code (or just ensure existence before the existing filter/find logic runs).

Why this will fix the job

All failing tests are crashing early due to missing reference/setup data that normally exists in non-isolated environments. CI test containers often start from a clean company without demo data; therefore, tests must create the master data they depend on.

What to verify in your PR

  • The “ensure” helpers run in both codeunits (or in a shared test library used by both).
  • Inserted records satisfy any mandatory fields/validation rules in your app version.
  • The tests no longer depend on environment/demo data (Routing Link and Capacity UoM Minutes should be created deterministically).

If you paste the contents (or at least the first ~30 lines) of:

  • Subc SCM Prod. Order codeunit method CreateRoutingAndUpdateItemSubc
  • Subc SCM Mfg. 70 codeunit method CreateWorkCenterSetup

…I can tailor the exact field assignments and provide a ready-to-commit patch aligned with your current code.

@AleksandricMarko AleksandricMarko added the Subcontracting Subcontracting related activities label May 8, 2026
@stevengrossGOB stevengrossGOB requested a review from a team as a code owner May 11, 2026 08:57
@stevengrossGOB stevengrossGOB requested a review from elbardel May 11, 2026 08:57
@stevengrossGOB stevengrossGOB requested a review from ChethanT May 11, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork Linked Issue is linked to a Azure Boards work item SCM GitHub request for SCM area Subcontracting Subcontracting related activities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants