Skip to content

Commit 3ee226c

Browse files
committed
Merge remote-tracking branch 'origin/main' into microbuild
2 parents 53f97d6 + 169c608 commit 3ee226c

1 file changed

Lines changed: 62 additions & 3 deletions

File tree

.github/copilot-instructions.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,68 @@
1212

1313
## Testing
1414

15-
* There should generally be one test project (under the `test` directory) per shipping project (under the `src` directory). Test projects are named after the project being tested with a `.Test` suffix.
16-
* Tests should use the Xunit testing framework.
17-
* Some tests are known to be unstable. When running tests, you should skip the unstable ones by running `dotnet test --filter "TestCategory!=FailsInCloudTest"`.
15+
**IMPORTANT**: This repository uses Microsoft.Testing.Platform (MTP v2) with xunit v3. Traditional `--filter` syntax does NOT work. Use the options below instead.
16+
17+
* There should generally be one test project (under the `test` directory) per shipping project (under the `src` directory). Test projects are named after the project being tested with a `.Tests` suffix.
18+
* Tests use xunit v3 with Microsoft.Testing.Platform (MTP v2). Traditional VSTest `--filter` syntax does NOT work.
19+
* Some tests are known to be unstable. When running tests, you should skip the unstable ones by using `-- --filter-not-trait "FailsInCloudTest=true"`.
20+
21+
### Running Tests
22+
23+
**Run all tests**:
24+
```bash
25+
dotnet test --no-build -c Release
26+
```
27+
28+
**Run tests for a specific test project**:
29+
```bash
30+
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release
31+
```
32+
33+
**Run a single test method**:
34+
```bash
35+
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-method ClassName.MethodName
36+
```
37+
38+
**Run all tests in a test class**:
39+
```bash
40+
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-class ClassName
41+
```
42+
43+
**Run tests with wildcard matching** (supports wildcards at beginning and/or end):
44+
```bash
45+
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-method "*Pattern*"
46+
```
47+
48+
**Run tests with a specific trait** (equivalent to category filtering):
49+
```bash
50+
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-trait "TraitName=value"
51+
```
52+
53+
**Exclude tests with a specific trait** (skip unstable tests):
54+
```bash
55+
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-not-trait "FailsInCloudTest=true"
56+
```
57+
58+
**Run tests for a specific framework only**:
59+
```bash
60+
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release --framework net9.0
61+
```
62+
63+
**List all available tests without running them**:
64+
```bash
65+
cd test/Library.Tests
66+
dotnet run --no-build -c Release --framework net9.0 -- --list-tests
67+
```
68+
69+
**Key points about test filtering with MTP v2 / xunit v3**:
70+
- Options after `--` are passed to the test runner, not to `dotnet test`
71+
- Use `--filter-method`, `--filter-class`, `--filter-namespace` for simple filtering
72+
- Use `--filter-trait` and `--filter-not-trait` for trait-based filtering (replaces `--filter "TestCategory=..."`)
73+
- Traditional VSTest `--filter` expressions do NOT work
74+
- Wildcards `*` are supported at the beginning and/or end of filter values
75+
- Multiple simple filters of the same type use OR logic, different types combine with AND
76+
- See `--help` for query filter language for advanced scenarios
1877

1978
## Coding style
2079

0 commit comments

Comments
 (0)