Skip to content

RunTests action - #2343

Open
spetersenms wants to merge 34 commits into
microsoft:mainfrom
spetersenms:spetersen/separateTestAction
Open

RunTests action#2343
spetersenms wants to merge 34 commits into
microsoft:mainfrom
spetersenms:spetersen/separateTestAction

Conversation

@spetersenms

@spetersenms spetersenms commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the preview useSeparateTestAction setting, defaulting to false, which moves normal test execution from RunPipeline into a new RunTests action using al runtests.

Flow

  1. RunPipeline builds and publishes the apps, creates the container, and keeps it alive.
  2. It exports the container name, generated credentials, and a runtime signal.
  3. The workflow conditionally invokes RunTests.
  4. RunTests selects the test apps, executes them with AlTool, and produces JUnit results for the existing analysis step.
  5. The existing cleanup step removes the container.

Notes

  • Only normal tests are moved. BCPT, page scripting, and multi-country tests remain in RunPipeline.
  • runTestsInAllInstalledTestApps uses the existing installTestAppsJson handoff rather than discovering every installed server app.
  • The optional testType setting supports UnitTest, IntegrationTest, and Uncategorized.
  • A custom RunTestsInBcContainer override can still replace the built-in AlTool runner.
  • BCH is still used for container creation, app installation and metadata, server and company discovery, test enumeration, and event-log collection. AlTool owns the actual test execution.

✅ Checklist

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

spetersenms and others added 2 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 <223556219+Copilot@users.noreply.github.com>
Comment thread Actions/RunTests/RunTests.ps1 Fixed
spetersenms and others added 23 commits August 7, 2026 10:04
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
@spetersenms
spetersenms marked this pull request as ready for review August 25, 2026 07:16
@spetersenms
spetersenms requested a review from a team as a code owner August 25, 2026 07:16
Copilot AI balanced review requested due to automatic review settings August 25, 2026 07:16

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.

Pull request overview

Adds an opt-in RunTests action that executes normal tests separately against the RunPipeline container.

Changes:

  • Adds separate test-action workflow wiring and settings.
  • Implements AlTool execution, JUnit output, overrides, and diagnostics.
  • Adds documentation and comprehensive Pester coverage.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Tests/RunTests.Test.ps1 Tests test selection and execution.
Tests/RunTests.Action.Test.ps1 Tests action wiring and credentials.
Tests/AnalyzeTests.Test.ps1 Tests generated JUnit analysis.
Tests/AlToolTestRunner.Test.ps1 Tests AlTool runner behavior.
Templates/Per Tenant Extension/.github/workflows/_BuildALGoProject.yaml Adds RunTests workflow step.
Templates/AppSource App/.github/workflows/_BuildALGoProject.yaml Adds RunTests workflow step.
Scenarios/settings.md Documents the new setting.
RELEASENOTES.md Announces separate test execution.
Actions/RunTests/RunTests.psm1 Selects and runs test apps.
Actions/RunTests/RunTests.ps1 Implements the action entry point.
Actions/RunTests/README.md Documents the action.
Actions/RunTests/AlToolTestRunner.psm1 Implements AlTool and JUnit integration.
Actions/RunTests/action.yaml Defines the composite action.
Actions/RunPipeline/RunPipeline.ps1 Keeps eligible containers alive.
Actions/RunPipeline/README.md Documents handoff variables.
Actions/AnalyzeTests/TestResultAnalyzer.ps1 Distinguishes failures from skipped tests.
Actions/.Modules/settings.schema.json Adds setting schema metadata.
Actions/.Modules/ReadSettings.psm1 Adds the default setting.
Suppressed comments (2)

Actions/RunPipeline/RunPipeline.ps1:559

  • -keepContainer disables Run-AlPipeline's normal teardown, but the new RunTests action and both workflows never invoke Remove-BcContainer. Every opt-in build therefore leaves the BC container running; if RunPipeline fails, RunTests is skipped and cannot perform cleanup either. Add an always-run cleanup path after event-log capture for both build and test failure paths, otherwise persistent self-hosted runners will accumulate containers.
        -keepContainer:$runTestsInSeparateAction `

Actions/RunTests/RunTests.ps1:88

  • Convert settings recursively here. Without -recurse, nested settings remain PSCustomObjects rather than the hashtables expected by the settings-processing helpers, making the separate action behave differently for nested settings.
$settings = $env:Settings | ConvertFrom-Json | ConvertTo-HashTable

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Actions/RunTests/RunTests.psm1 Outdated
Comment thread Actions/RunTests/AlToolTestRunner.psm1
Comment thread Actions/.Modules/settings.schema.json
Comment thread Actions/RunPipeline/RunPipeline.ps1
Comment thread Actions/RunTests/RunTests.ps1
@mazhelez

Copy link
Copy Markdown
Collaborator

📦 Release Notes Update Required

AL-Go v9.2 has been released, and your changes to RELEASENOTES.md appear to be under that version's section.

Action needed: Please move your release notes entry to above the ## v9.2 heading so it will be included in the next release.

Example
## Changes to be included in the next release

- Your change here ✅

## v9.2

- Already released changes

Thank you for contributing to AL-Go! 🙏

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.

4 participants