[Subcontracting] Move subcontracting tests from Base Test App to Subcontracting Test App#7740
Conversation
- Updated references in SubcPurchSubcontTest, SubcSubcontractingSyncTest, and SubcSubcontractingTest codeunits for consistency. - Improved code readability and maintainability by standardizing library naming.
Missing test compared to W1 disabled testsCompared all
Scenario: Test Standard Costing of Subcontracting Order with Flushing method - Manual. Subcontract and Output Cost different from Expected. Parameters: The PR includes the AddCurr variant ( |
|
@ChethanT I have added the missing test |
|
@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:
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 routingsIn Code suggestion (AL): add an “ensure” step at the start of 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 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 setupIn 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 Why this will fix the jobAll 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
If you paste the contents (or at least the first ~30 lines) of:
…I can tailor the exact field assignments and provide a ready-to-commit patch aligned with your current code. |
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