Add Test Isolation support#2216
Conversation
There was a problem hiding this comment.
Pull request overview
Adds opt-in “test isolation” support to AL-Go so a single test stage can be partitioned across multiple test runners (to satisfy mixed RequiredTestIsolation requirements) while preserving existing Run-AlPipeline behaviors like disabled tests handling and result aggregation.
Changes:
- Introduces new
testIsolationsetting (defaults, schema validation, and documentation). - Adds a
RunTestsInBcContaineroverride hook inRunPipelinethat runs partitions + a default “everything else” pass. - Adds Pester coverage for the new partitioning scriptblock and settings schema shape/validation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/TestIsolation.Test.ps1 | New Pester tests covering partition invocation behavior, negated default filter construction, parameter forwarding, and failure aggregation. |
| Tests/ReadSettings.Test.ps1 | Extends schema tests to cover testIsolation defaults and schema validation rules. |
| Scenarios/settings.md | Documents the new testIsolation setting in the settings reference table. |
| Scenarios/TestIsolation.md | Adds a dedicated scenario doc describing configuration, semantics, compatibility, and edge cases. |
| RELEASENOTES.md | Adds release notes entry describing the new opt-in test isolation partitioning capability. |
| README.md | Links the new Test Isolation scenario from the main scenarios list. |
| Actions/RunPipeline/RunPipeline.ps1 | Wires testIsolation into Run-AlPipeline by injecting a partitioning RunTestsInBcContainer scriptblock and emitting telemetry. |
| Actions/.Modules/settings.schema.json | Adds testIsolation schema (object shape, required keys, and partition entry validation). |
| Actions/.Modules/TestIsolation.psm1 | New module that builds the partitioning scriptblock and computes the negated default codeunit-range filter. |
| Actions/.Modules/ReadSettings.psm1 | Adds testIsolation to default settings so it participates in the normal settings merge+validation pipeline. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
(e.g. '..60199|60302..') instead of '<>' negation, which the BC filter grammar does not support for ranges; skip the call when partitions cover the entire ID space and warn on overlaps Wrap an existing RunTestsInBcContainer override instead of replacing it (new InnerScriptBlock parameter) Restrict codeunits filter syntax in the schema to single IDs and closed ranges joined by '|' Fix schema negative tests passing vacuously when no error was thrown; add coverage for complement, wrapping and validation
|
@mazhelez Thanks for the review, both points are addressed in the latest commit, plus one issue I found while re-checking the filter logic: 1. Existing 2. Regarding an alternative without the override hook: 3. Fixed the default-runner exclusion filter for range partitions. The BC filter grammar only supports
|
|
@spetersenms should be good now |
Add Test Isolation support
Why
BC runtime 16 (2025 W2) added the
RequiredTestIsolationproperty on test codeunits. The standard BC test runner has a single, fixedTestIsolationvalue, so any project that mixes codeunits with different isolation requirements cannot run them all under one runner, those tests get excluded from CI.AL-Go today makes one blanket
Run-TestsInBcContainercall per test app under the default runner. Test codeunits that need a non-default runner (e.g.TestIsolation = Disabledfor long-running integration tests that must not roll back) have to be placed indisabledtests.jsonand run manually, losing CI coverage.This contribution closes that gap.
Discussion reference
#1565
How
A new opt-in
testIsolationsetting lets projects partition the test stage:When
enabled,RunPipelineinstalls a-RunTestsInBcContainerscriptblock intoRun-AlPipelinethat, per test app:Run-TestsInBcContaineronce per entry inpartitions, with-testRunnerCodeunitIdand-testCodeunitRangeset from the entry.defaultRunnerCodeunitIdwhose-testCodeunitRangeis the negation of every explicit partition's filter, so codeunits not in any partition run exactly once under the default runner.The scriptblock forwards all other Run-AlPipeline parameters verbatim, so
disabledTests.jsonhandling, JUnit result appending, container lifecycle, anduseCompilerFoldersupport continue to work unchanged. Feature is strictly additive and off by default.Validation
disabledtests.jsonfor lack of aTestIsolation = Disabledrunner now execute successfully under standard BCApps runner130451, while the remaining test codeunits (99201–99203) run under the default runner in the same build — proving both the partition call and the negated-filter fallback work against real BcContainerHelper.