Skip to content

Add dotnet.config to specify MTP for dotnet test #10836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,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 "TestingBuilderHasAllPropertiesFromRealBuilder"
```
dotnet.sh test tests/Aspire.Hosting.Testing.Tests/Aspire.Hosting.Testing.Tests.csproj --filter "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.
Expand All @@ -60,10 +61,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 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 "TestName" --filter-not-trait "quarantined=true"
dotnet.sh test tests/Project.Tests/Project.Tests.csproj --filter "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.
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,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
Expand All @@ -249,14 +250,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
Expand Down
2 changes: 2 additions & 0 deletions dotnet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dotnet.test.runner]
name = "Microsoft.Testing.Platform"
2 changes: 1 addition & 1 deletion tests/helix/send-to-helix-buildonhelixtests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<_TestBlameArguments Include="--crashdump-type Full" />

<!-- Using `dotnet test` for the project directly here -->
<_TestRunCommandArguments Include="dotnet test -- --results-directory $(_HelixLogsPath) --report-trx --report-trx-filename TestResults.trx" />
<_TestRunCommandArguments Include="dotnet test --results-directory $(_HelixLogsPath) --no-progress --report-trx --report-trx-filename TestResults.trx" />
<_TestRunCommandArguments Include="@(_TestBlameArguments, ' ')" />

<_TestRunCommandArguments Include="--filter-not-trait &quot;quarantined=true&quot;" />
Expand Down
Loading