Skip to content

RunTests - test discovery using ALTool instead of BcContainerHelper - #2426

Open
spetersenms wants to merge 71 commits into
microsoft:mainfrom
spetersenms:spetersen-microsoft-separate-test-action-discovery
Open

spetersenms wants to merge 71 commits into
microsoft:mainfrom
spetersenms:spetersen-microsoft-separate-test-action-discovery

Conversation

@spetersenms

@spetersenms spetersenms commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

❔What, Why & How

The initial implementation of RunTests used the legacy BcContainerHelper function for test discovery. ALTool has since added support for this functionality. This PR updates RunTests to use the ALTool test discovery.

There is one current limitation which is that ALTool does not support filtering by test type. This means that the test type setting for testing is ignored for RunTests until this is implemented in ALTool.

Disabled test logic is still somewhat long since ALTool doesn't support a list of tests not to run, only a list of tests to run. This means AL-Go has to first find the full list of tests, then the list of tests to skip and then filter based on that and finally pass that list to the ALTool test runner.

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

spetersenms and others added 30 commits August 6, 2026 16:32
Introduces a new opt-in RunTests action that moves normal test execution
(testFolders) out of the RunPipeline action. When useSeparateTestAction is
true, RunPipeline compiles, publishes and installs apps and keeps the build
container alive, but skips normal tests; the RunTests action then runs those
tests against the same container and produces TestResults.xml. BCPT and page
scripting tests are unchanged. Behavior is unchanged when the setting is false.

Includes the new setting (ReadSettings, settings.schema.json, settings.md),
the RunPipeline keep-alive guard, template _BuildALGoProject wiring, release
notes and Pester tests.

Co-authored-by: Copilot App <[email protected]>
The separate RunTests action now runs normal tests through Microsoft's
headless al runtests (AlTool) CLI by default instead of BcContainerHelper.
The runner resolves the kept-alive container's connection settings host-side
from the container name, installs the AL developer tools as a dotnet global
tool, runs the test codeunits batched (with an isolated fallback/rerun pass)
and emits the same TestResults.xml (JUnit) schema, so downstream test result
analysis is unchanged. No RunPipeline change is required.

BcContainerHelper remains available via a RunTestsInBcContainer override
script, which fully replaces the built-in AlTool runner (this is how, for
example, BCApps supplies its own runner and how Legacy test-type tests are
handled). The AlTool runner does not run Legacy test types or tests that
require UI/client-callback interaction; this is documented as a known
limitation.

Co-authored-by: Copilot App <[email protected]>
The official released al runtests tool does not support --testplan, so the
batch-first path in AlToolTestRunner hard-set �llPassed=false whenever the
batch failed to connect and never reset it, making every run falsely report
FAILED. Remove the batching path entirely and run each test codeunit in its
own �l runtests <codeunitId> --testmethods --raw invocation, with the
existing rerun-on-failure pass. �llPassed now derives solely from real
per-method outcomes via Add-JUnitTestSuite.

- Delete Invoke-AlBatchRunTests, ConvertFrom-AlBatchOutput,
  ConvertTo-AlTestPlanJson and their Export-ModuleMember entries.
- Update README and RELEASENOTES to per-codeunit wording.
- Drop the two batch-specific unit test contexts.

Co-authored-by: Copilot App <[email protected]>
…. Using -recurse flag for ConvertTo-HashTable

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

AlTool is resolved before the no-test-apps return, so projects with no test packages can fail on unnecessary tool installation instead of skipping test execution.

1 open issue
What changed in this PR

Migrates the separate RunTests action from BcContainerHelper test discovery to ALTool package discovery while preserving disabled-test filtering and batched execution.

Changes:

  • Discovers app metadata and test methods directly from .app packages.
  • Warns that built-in testType filtering is unsupported while preserving the value for custom overrides.
  • Updates unit tests, end-to-end assertions, and documentation for the discovery flow.
File Description
Tests/​RunTests.Test.ps1 Updates discovery mocks and runner integration assertions.
Tests/​AlToolTestRunner.Test.ps1 Tests discovery parsing, validation, filtering, and runner inputs.
Scenarios/​settings.md Documents the testType filtering limitation.
RELEASENOTES.md Describes package discovery and updated runner limitations.
e2eTests/​scenarios/​SeparateTestAction/​runtest.ps1 Checks discovery and selected-method log output.
Actions/​RunTests/​RunTests.psm1 Integrates package discovery and passes codeunits to execution.
Actions/​RunTests/​README.md Explains ALTool discovery and remaining BcContainerHelper responsibilities.
Actions/​RunTests/​AlToolTestRunner.psm1 Adds package discovery and filters discovered tests for execution.
Actions/​.Modules/​settings.schema.json Aligns the testType description with current behavior.

Review effort: Balanced

Comment thread Actions/RunTests/RunTests.psm1 Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the switch to ALTool-based local test discovery.

No open issues 🎉

Review effort: Balanced

@spetersenms
spetersenms marked this pull request as ready for review November 12, 2026 16:10
@spetersenms
spetersenms requested a review from a team as a code owner November 12, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The log assertion relies on debug-only output without enabling step debugging, causing a normal successful run to fail the check.

1 open issue

Review effort: Balanced

Comment thread RELEASENOTES.md Outdated
A new `useSeparateTestAction` complex setting (default `{ "enabled": false, "testType": "" }`) runs normal tests (`testFolders`) in a dedicated `RunTests` action when `enabled` is `true`. The separate action is used when tests are built and enabled and the build uses one local container. Normal tests remain in `RunPipeline` for builds with `additionalCountries`, no published apps, or test-data import callbacks that would otherwise have no remaining RunPipeline test category. BCPT and page scripting tests remain in `RunPipeline`.

The action uses AlTool by default, running each app's enabled normal tests in one batch and connection. It honors `disabledTests.json` definitions and the optional `useSeparateTestAction.testType` value. The built-in runner supports `UnitTest`, `IntegrationTest`, and `Uncategorized`, while custom `RunTestsInBcContainer` overrides may interpret other values such as `Legacy`. Test results remain available to AnalyzeTests and are included in the build artifacts when produced. Failure diagnostics include a refreshed container event log with events from the separate test run.
The action uses AlTool by default, discovering tests locally from each exact app package and running each app's enabled normal tests in one batch and connection. It honors `disabledTests.json` definitions. Because `al listtests` does not support TestType filtering, the built-in runner warns and ignores a nonblank `useSeparateTestAction.testType`; custom `RunTestsInBcContainer` overrides still receive the configured value. Test results remain available to AnalyzeTests and are included in the build artifacts when produced. Failure diagnostics include a refreshed container event log with events from the separate test run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new version of AL-Go (v10.1) has been released.

Please move your release notes changes to above the ## v10.1 section in the RELEASENOTES.md file.

This ensures your changes are included in the next release rather than being listed under an already-released version.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants