Skip to content

OSOE-1308: Default .NET test workflows to Microsoft Testing Platform - #673

Open
Piedone wants to merge 6 commits into
devfrom
issue/OSOE-1308
Open

OSOE-1308: Default .NET test workflows to Microsoft Testing Platform#673
Piedone wants to merge 6 commits into
devfrom
issue/OSOE-1308

Conversation

@Piedone

@Piedone Piedone commented Sep 5, 2026

Copy link
Copy Markdown
Member

Default the modern .NET test workflows to Microsoft Testing Platform and generate GitHub Actions summaries with the native reporter. Use evaluated MSBuild properties to find test applications and process exit codes to determine success, preserving filtered solution runs, test output, TRX artifacts, diagnostics, and hang dump collection. Retain an explicit VSTest option for legacy consumers; msbuild-and-test continues to select it.

Part of Lombiq/Testing-Toolbox#92. Coordinated OSOCE integration: Lombiq/Open-Source-Orchard-Core-Extensions#1335.

This is a breaking change requiring .NET SDK 10+, the global.json MTP runner selection, and reporting extensions in each test project. Docs/MicrosoftTestingPlatform.md describes migration and the v6.0.0 release step. Internal action references use issue/OSOE-1308 during review and must return to dev before merge; publish v6.0.0 through the existing release-branch workflow after integration.

Validation: the local regression fixture passes filtering, theory discovery, passing-test output, native summaries, TRX reporting, diagnostics, empty selections, and failure exit-code checks. PowerShell analysis and YAML validation pass. Added Windows/Ubuntu CI regression coverage. The fixture explicitly clears the expected negative scenario's exit status before returning to the CI shell.

CI verification: the MTP regression suite passes on Ubuntu and Windows; spelling, YAML, branch-reference, and PR validation checks pass.


namespace TestDotnet;

public class ActionFixture(ITestOutputHelper output)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Didn't we reject using class primary constructors (as opposed to record primary constructors) in the past? (see)

Comment on lines +7 to +12
$savedEnvironment = @{}

foreach ($name in @('PATH', 'GITHUB_ACTIONS', 'GITHUB_OUTPUT', 'GITHUB_STEP_SUMMARY', 'GITHUB_WORKSPACE', 'LGHA_TEST_FAILURE'))
{
$savedEnvironment[$name] = [Environment]::GetEnvironmentVariable($name)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This data is only used in a ``foreach` so it doesn't actually need to be a dictionary:

Suggested change
$savedEnvironment = @{}
foreach ($name in @('PATH', 'GITHUB_ACTIONS', 'GITHUB_OUTPUT', 'GITHUB_STEP_SUMMARY', 'GITHUB_WORKSPACE', 'LGHA_TEST_FAILURE'))
{
$savedEnvironment[$name] = [Environment]::GetEnvironmentVariable($name)
}
$environmentVariableNames = @('PATH', 'GITHUB_ACTIONS', 'GITHUB_OUTPUT', 'GITHUB_STEP_SUMMARY', 'GITHUB_WORKSPACE', 'LGHA_TEST_FAILURE')
$savedEnvironment = Get-ChildItem Env: | Where-Object { $PSItem.Name -in $environmentVariableNames }

$logPath = Join-Path $artifactPath "$Name.log"

$arguments = @(
'-NoProfile', '-File', "$actionPath/Invoke-SolutionOrProjectTests.ps1"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two unrelated parameters packed on the same line.

Suggested change
'-NoProfile', '-File', "$actionPath/Invoke-SolutionOrProjectTests.ps1"
'-NoProfile',
'-File', "$actionPath/Invoke-SolutionOrProjectTests.ps1"

Comment on lines +80 to +83
foreach ($entry in $savedEnvironment.GetEnumerator())
{
[Environment]::SetEnvironmentVariable($entry.Key, $entry.Value)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To me using Env: feels more appropriate for a PowerShell script.

Suggested change
foreach ($entry in $savedEnvironment.GetEnumerator())
{
[Environment]::SetEnvironmentVariable($entry.Key, $entry.Value)
}
$savedEnvironment | ForEach-Object { Set-Item ('Env:' + $PSItem.Key) -Value $PSItem.Value }

or formatted

Suggested change
foreach ($entry in $savedEnvironment.GetEnumerator())
{
[Environment]::SetEnvironmentVariable($entry.Key, $entry.Value)
}
$savedEnvironment | ForEach-Object {
Set-Item ('Env:' + $PSItem.Key) -Value $PSItem.Value
}

working-directory: ${{ inputs.build-directory }}
run: |
$switches = @{
TestPlatform = '${{ inputs.test-platform }}'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since MTP is for .NET 10+ only, do we want to do something like this to reduce the breakingness of the change?

$dotnetVersion = [Version](dotnet --version)
if ($dotnetVersion.Major -lt 10)
{
    $switches['TestPlatform'] = 'VSTest'
    Write-GitHub "The test platform is set to `"VSTest`" because you are using .NET version ($dotnetVersion) older than .NET 10. Please set the `"test-platform`" input to `"VSTest`" explicitly, to remove this warning."
}

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.

2 participants