diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 5e33246619d..2ebde1bfac1 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -50,9 +50,10 @@ In building and testing, never use `dotnet` without extension. Use `./dotnet.sh` Note that tests for a project can be executed without first building from the root. -(4) To run just certain tests, it's important to include the filter after `--`, for example: +(4) To run just certain tests, it's important to include the filter, for example: -dotnet.sh test tests/Aspire.Hosting.Testing.Tests/Aspire.Hosting.Testing.Tests.csproj --logger "console;verbosity=detailed" -- --filter-method "TestingBuilderHasAllPropertiesFromRealBuilder" +``` +dotnet.sh test --project tests/Aspire.Hosting.Testing.Tests/Aspire.Hosting.Testing.Tests.csproj --filter-method "TestingBuilderHasAllPropertiesFromRealBuilder" ``` Important: Avoid passing `--no-build` unless you have just built in the same session and there have been no code changes since. In automation or while iterating on code, omit `--no-build` so changes are compiled and picked up by the test run. @@ -63,10 +64,10 @@ When running tests in automated environments (including Copilot agent), **always ```bash # Correct - excludes quarantined tests (use this in automation) -dotnet.sh test tests/Project.Tests/Project.Tests.csproj -- --filter-not-trait "quarantined=true" +dotnet.sh test --project tests/Project.Tests/Project.Tests.csproj --filter-not-trait "quarantined=true" # For specific test filters, combine with quarantine exclusion -dotnet.sh test tests/Project.Tests/Project.Tests.csproj -- --filter-method "TestName" --filter-not-trait "quarantined=true" +dotnet.sh test --project tests/Project.Tests/Project.Tests.csproj --filter-method "TestName" --filter-not-trait "quarantined=true" ``` Never run all tests without the quarantine filter in automated environments, as this will include flaky tests that are known to fail intermittently. diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ea3dd0dc262..09701a1f7f6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -277,6 +277,7 @@ jobs: run: > dotnet ${{ env.TEST_ASSEMBLY_NAME }}.dll --ignore-exit-code 8 + --no-progress --report-trx --report-trx-filename "${{ inputs.testShortName }}.trx" --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump @@ -297,14 +298,15 @@ jobs: # So, we manually set NUGET_PACKAGES NUGET_PACKAGES: ${{ github.workspace }}/.packages run: > - ${{ env.DOTNET_SCRIPT }} test ${{ env.TEST_PROJECT_PATH }} + ${{ env.DOTNET_SCRIPT }} test --project ${{ env.TEST_PROJECT_PATH }} /p:ContinuousIntegrationBuild=true /p:TrxFileNamePrefix="${{ inputs.testShortName }}" -bl:${{ github.workspace }}/testresults/test.binlog --no-restore --no-build - -- + --no-launch-profile --ignore-exit-code 8 + --no-progress --report-trx --hangdump --hangdump-timeout ${{ inputs.testHangTimeout }} --crashdump diff --git a/dotnet.config b/dotnet.config new file mode 100644 index 00000000000..da0410e32d5 --- /dev/null +++ b/dotnet.config @@ -0,0 +1,2 @@ +[dotnet.test.runner] +name = "Microsoft.Testing.Platform" diff --git a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj index 76b55e53ece..2d2e447563a 100644 --- a/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj +++ b/tests/Aspire.Playground.Tests/Aspire.Playground.Tests.csproj @@ -112,6 +112,8 @@ + + diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 2d0e0ccb11f..310734fa081 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -16,6 +16,8 @@ + + + + <_DotnetExecutable Condition="'$(OS)' == 'Windows_NT'">%HELIX_CORRELATION_PAYLOAD%\dotnet-10\dotnet.exe + <_DotnetExecutable Condition="'$(OS)' != 'Windows_NT'">$HELIX_CORRELATION_PAYLOAD/dotnet-10/dotnet + <_TestRunCommandArguments Remove="@(_TestRunCommandArguments)" /> @@ -34,8 +38,10 @@ <_TestBlameArguments Include="--crashdump" /> <_TestBlameArguments Include="--crashdump-type Full" /> + <_TestRunCommandArguments Include="$(_DotnetExecutable) --info $(_ShellCommandSeparator)" /> + - <_TestRunCommandArguments Include="dotnet test -- --results-directory $(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx" /> + <_TestRunCommandArguments Include="$(_DotnetExecutable) test --results-directory $(_HelixLogsPath) --no-progress --report-trx --report-trx-filename TestResults.trx" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> <_TestRunCommandArguments Include="--filter-not-trait "quarantined=true"" /> @@ -45,7 +51,8 @@ <_TestRunCommand>@(_TestRunCommandArguments, ' ') - <_TestRunCommand>dotnet build -bl:$(_HelixLogsPath)/build.binlog /p:TreatWarningsAsErrors=true $(_ShellCommandSeparator) $(_TestRunCommand) + <_TestRunCommand>$(_DotnetExecutable) build -bl:$(_HelixLogsPath)/build.binlog /p:TreatWarningsAsErrors=true $(_ShellCommandSeparator) $(_TestRunCommand) + <_TestRunCommand Condition="'$(OS)' != 'Windows_NT'">ls %HELIX_CORRELATION_PAYLOAD% $(_ShellCommandSeparator) %HELIX_CORRELATION_PAYLOAD%\dotnet-10 $(_ShellCommandSeparator) $(_TestRunCommand) <_TestRunCommand Condition="'$(HelixPerWorkItemPreCommand)' != ''">$(HelixPerWorkItemPreCommand) $(_ShellCommandSeparator) $(_TestRunCommand) <_SetPathEnvVar Condition="'$(OS)' != 'Windows_NT'">PATH=${SDK_FOR_TEMPLATES_TESTING_PATH}:$PATH diff --git a/tests/helix/send-to-helix-inner.proj b/tests/helix/send-to-helix-inner.proj index 0680692475d..950ef47d236 100644 --- a/tests/helix/send-to-helix-inner.proj +++ b/tests/helix/send-to-helix-inner.proj @@ -22,7 +22,7 @@ <_AzureFunctionsCliUrl Condition="'$(OS)' == 'Windows_NT'">https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.7512/Azure.Functions.Cli.min.win-x64.4.0.7512.zip <_AzureFunctionsCliUrl Condition="'$(OS)' != 'Windows_NT'">https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.7512/Azure.Functions.Cli.linux-x64.4.0.7512.zip - <_DefaultSdkDirNameForTests>dotnet-tests + dotnet-tests @@ -69,7 +69,7 @@ So, ignore exit code 8 (zero tests ran) https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-exit-codes --> - <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx --filter-not-trait "category=failing" --ignore-exit-code 8" /> + <_TestRunCommandArguments Include="$(_SetExecutableBitCommand)dotnet exec $(_TestNameEnvVar).dll --results-directory:$(_HelixLogsPath) --no-progress --report-trx --report-trx-filename TestResults.trx --filter-not-trait "category=failing" --ignore-exit-code 8" /> <_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" /> @@ -91,11 +91,11 @@ - - + + - - + + @@ -156,11 +156,11 @@ - set PATH=%HELIX_CORRELATION_PAYLOAD%\$(_DefaultSdkDirNameForTests)%3B%PATH% - export PATH=$HELIX_CORRELATION_PAYLOAD/$(_DefaultSdkDirNameForTests):$PATH + set PATH=%HELIX_CORRELATION_PAYLOAD%\$(SdkDirNameForTests)%3B%PATH% + export PATH=$HELIX_CORRELATION_PAYLOAD/$(SdkDirNameForTests):$PATH - $(HelixPerWorkItemPreCommand) & set DOTNET_ROOT=%HELIX_CORRELATION_PAYLOAD%\$(_DefaultSdkDirNameForTests) - $(HelixPerWorkItemPreCommand) && export DOTNET_ROOT=$HELIX_CORRELATION_PAYLOAD/$(_DefaultSdkDirNameForTests) + $(HelixPerWorkItemPreCommand) & set DOTNET_ROOT=%HELIX_CORRELATION_PAYLOAD%\$(SdkDirNameForTests) + $(HelixPerWorkItemPreCommand) && export DOTNET_ROOT=$HELIX_CORRELATION_PAYLOAD/$(SdkDirNameForTests) @@ -188,7 +188,7 @@ - +