Skip to content

Commit c3fafaf

Browse files
committed
docs: update --test usage from docs
1 parent 27ca88d commit c3fafaf

File tree

7 files changed

+38
-58
lines changed

7 files changed

+38
-58
lines changed

README.zh.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public class CalculatorTests
234234

235235
```sh
236236
# 运行测试
237-
dotnet-exec test.cs --test
237+
dotnet-exec test test.cs
238238
```
239239

240240
### 配置文件
@@ -358,7 +358,6 @@ dotnet-exec deploy-script.cs --reference "nuget:Docker.DotNet"
358358
| `--using` | `-u` | 添加 using 语句 | `-u "System.Text.Json"` |
359359
| `--entry` | | 指定入口方法 | `--entry MainTest` |
360360
| `--web` | | 添加 Web 框架引用 | `--web` |
361-
| `--test` | | 启用测试模式 | `--test` |
362361
| `--profile` | | 使用配置文件 | `--profile web-dev` |
363362

364363
### 编译选项

docs/articles/en/repl.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ Reference added
113113
# REPL with web references
114114
dotnet-exec --web
115115

116-
# REPL with testing references
117-
dotnet-exec --test
118-
119116
# REPL with specific framework
120117
dotnet-exec --framework Microsoft.AspNetCore.App
121118

docs/articles/zh/advanced-usage.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ dotnet-exec alias set web-test \
365365
--reference "nuget:Microsoft.AspNetCore.Mvc.Testing" \
366366
--reference "nuget:xunit" \
367367
--web \
368-
--test \
369368
--using "Microsoft.AspNetCore.Mvc.Testing" \
370369
--using "Xunit"
371370

@@ -393,7 +392,7 @@ public class CustomMiddleware : IOptionsConfigureMiddleware
393392
}
394393
```
395394

396-
### 插件系统
395+
### 插件系统(TBD)
397396

398397
```sh
399398
# 加载自定义插件
@@ -405,4 +404,4 @@ dotnet-exec script.cs \
405404
--plugin ./Plugin2.dll
406405
```
407406

408-
这些高级功能让 dotnet-exec 成为一个强大而灵活的 C# 脚本执行工具,适用于从简单自动化到复杂企业级场景的各种用例。
407+
这些高级功能让 dotnet-exec 成为一个强大而灵活的 C# 脚本执行工具,适用于从简单自动化到复杂企业级场景的各种用例。

docs/articles/zh/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public class CalculatorTests
268268

269269
```sh
270270
# 运行测试
271-
dotnet-exec test-example.cs --test
271+
dotnet-exec test test-example.cs
272272
```
273273

274274
## 配置文件和别名

docs/articles/zh/profiles-and-aliases.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dotnet-exec config set-profile web-dev \
2424

2525
# 创建测试配置文件
2626
dotnet-exec config set-profile testing \
27-
--test \
27+
--reference "nuget:xunit" \
2828
--reference "nuget:Moq" \
2929
--reference "nuget:FluentAssertions" \
3030
--using "Moq" \
@@ -88,7 +88,6 @@ dotnet-exec config set-profile prod \
8888

8989
# 测试环境配置
9090
dotnet-exec config set-profile test \
91-
--test \
9291
--reference "nuget:Microsoft.AspNetCore.Mvc.Testing" \
9392
--reference "nuget:Testcontainers" \
9493
--using "Microsoft.AspNetCore.Mvc.Testing" \
@@ -173,7 +172,6 @@ dotnet-exec alias set web-script \
173172

174173
# 测试别名
175174
dotnet-exec alias set test-script \
176-
--test \
177175
--reference "nuget:FluentAssertions" \
178176
--using "FluentAssertions"
179177
```
@@ -221,8 +219,7 @@ dotnet-exec alias set api-test \
221219
--reference "nuget:Microsoft.AspNetCore.Mvc.Testing" \
222220
--using "RestSharp" \
223221
--using "Xunit" \
224-
--using "Microsoft.AspNetCore.Mvc.Testing" \
225-
--test
222+
--using "Microsoft.AspNetCore.Mvc.Testing"
226223

227224
# 数据库脚本别名
228225
dotnet-exec alias set db-script \
@@ -289,18 +286,17 @@ dotnet-exec alias import --file .dotnet-exec/project-aliases.json
289286

290287
```sh
291288
# 创建配置模板
292-
dotnet-exec config create-template web-app \
289+
dotnet-exec profile set web-app \
293290
--web \
294-
--test \
295291
--reference "nuget:Microsoft.EntityFrameworkCore.SqlServer" \
296292
--reference "nuget:Microsoft.AspNetCore.Authentication.JwtBearer" \
297293
--reference "nuget:Serilog.AspNetCore" \
298294
--reference "nuget:FluentValidation.AspNetCore"
299295

300296
# 基于模板创建配置文件
301-
dotnet-exec config from-template web-app my-web-project \
302-
--override-reference "nuget:Microsoft.EntityFrameworkCore.PostgreSQL" \
303-
--add-reference "nuget:Npgsql.EntityFrameworkCore.PostgreSQL"
297+
dotnet-exec profile set web-app my-web-project \
298+
--reference "-nuget:Microsoft.EntityFrameworkCore.PostgreSQL" \
299+
--reference "nuget:Npgsql.EntityFrameworkCore.PostgreSQL"
304300
```
305301

306302
## CI/CD 集成
@@ -316,10 +312,10 @@ jobs:
316312
run-scripts:
317313
runs-on: ubuntu-latest
318314
steps:
319-
- uses: actions/checkout@v3
315+
- uses: actions/checkout@v4
320316

321317
- name: Setup .NET
322-
uses: actions/setup-dotnet@v3
318+
uses: actions/setup-dotnet@v4
323319
with:
324320
dotnet-version: '8.0.x'
325321

docs/articles/zh/repl.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,8 @@ DaysInMonth
113113
# 带 Web 引用的 REPL
114114
dotnet-exec --web
115115

116-
# 带测试引用的 REPL
117-
dotnet-exec --test
118-
119116
# 带特定框架的 REPL
120-
dotnet-exec --framework Microsoft.AspNetCore.App
117+
dotnet-exec --reference "framework:Microsoft.AspNetCore.App"
121118

122119
# 带多个引用的 REPL
123120
dotnet-exec --reference "nuget:Dapper" --reference "nuget:MySql.Data"
@@ -129,7 +126,7 @@ dotnet-exec --reference "nuget:Dapper" --reference "nuget:MySql.Data"
129126

130127
```sh
131128
# 创建 Web 开发 REPL 配置文件
132-
dotnet-exec config set-profile web-repl \
129+
dotnet-exec profile set web-repl \
133130
--web \
134131
--reference "nuget:Dapper" \
135132
--reference "nuget:Microsoft.EntityFrameworkCore.SqlServer" \

docs/articles/zh/testing-guide.md

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
### 启用测试模式
88

99
```sh
10-
# 使用测试标志
11-
dotnet-exec script.cs --test
10+
# 使用测试
11+
dotnet-exec test script.cs
1212

1313
# 等同于添加 xUnit 引用
14-
dotnet-exec script.cs --reference "nuget:xunit" --reference "nuget:xunit.runner.visualstudio"
15-
16-
# 测试模式 REPL
17-
dotnet-exec --test
14+
dotnet-exec script.cs --reference "nuget:xunit.v3" --using "xunit"
1815
```
1916

2017
### 简单单元测试
@@ -58,7 +55,7 @@ public class Calculator
5855

5956
```sh
6057
# 执行测试
61-
dotnet-exec simple-test.cs --test
58+
dotnet-exec test simple-test.cs
6259
```
6360

6461
## 高级测试场景
@@ -67,8 +64,7 @@ dotnet-exec simple-test.cs --test
6764

6865
```sh
6966
# 添加 FluentAssertions 进行更好的断言
70-
dotnet-exec test.cs \
71-
--test \
67+
dotnet-exec test test.cs \
7268
--reference "nuget:FluentAssertions"
7369
```
7470

@@ -111,8 +107,7 @@ public class CollectionTests
111107

112108
```sh
113109
# 添加 Moq 进行模拟
114-
dotnet-exec test.cs \
115-
--test \
110+
dotnet-exec test test.cs \
116111
--reference "nuget:Moq" \
117112
--reference "nuget:Microsoft.Extensions.DependencyInjection"
118113
```
@@ -193,8 +188,7 @@ public class UserServiceTests
193188

194189
```sh
195190
# Web API 测试设置
196-
dotnet-exec api-test.cs \
197-
--test \
191+
dotnet-exec test api-test.cs \
198192
--web \
199193
--reference "nuget:Microsoft.AspNetCore.Mvc.Testing"
200194
```
@@ -287,8 +281,7 @@ public class WeatherApiTests : IClassFixture<CustomWebApplicationFactory>
287281

288282
```sh
289283
# EF Core 测试设置
290-
dotnet-exec ef-test.cs \
291-
--test \
284+
dotnet-exec test ef-test.cs \
292285
--reference "nuget:Microsoft.EntityFrameworkCore.InMemory" \
293286
--reference "nuget:Microsoft.EntityFrameworkCore"
294287
```
@@ -471,8 +464,7 @@ public class AsyncHttpServiceTests
471464

472465
```sh
473466
# 添加 BenchmarkDotNet 进行性能测试
474-
dotnet-exec benchmark-test.cs \
475-
--test \
467+
dotnet-exec benchmark-test.cs -c Release \
476468
--reference "nuget:BenchmarkDotNet"
477469
```
478470

@@ -539,38 +531,38 @@ public class Program
539531

540532
```sh
541533
# 创建测试专用配置
542-
dotnet-exec config set-profile unit-tests \
543-
--test \
534+
dotnet-exec profile set unit-tests \
535+
--reference "xunit.v3" \
544536
--reference "nuget:FluentAssertions" \
545537
--reference "nuget:Moq" \
546538
--using "Xunit" \
547539
--using "FluentAssertions" \
548540
--using "Moq"
549541

550542
# 集成测试配置
551-
dotnet-exec config set-profile integration-tests \
552-
--test \
543+
dotnet-exec profile set integration-tests \
553544
--web \
545+
--reference "xunit.v3" \
554546
--reference "nuget:Microsoft.AspNetCore.Mvc.Testing" \
555547
--reference "nuget:Microsoft.EntityFrameworkCore.InMemory" \
556548
--reference "nuget:Testcontainers"
557549

558550
# 使用配置运行测试
559-
dotnet-exec test.cs --profile unit-tests
551+
dotnet-exec test test.cs --profile unit-tests
560552
```
561553

562554
### 测试别名
563555

564556
```sh
565557
# 创建测试别名
566558
dotnet-exec alias set unit-test \
567-
--test \
559+
--reference "xunit.v3" \
568560
--reference "nuget:FluentAssertions" \
569561
--using "FluentAssertions"
570562

571563
dotnet-exec alias set api-test \
572-
--test \
573564
--web \
565+
--reference "xunit.v3" \
574566
--reference "nuget:Microsoft.AspNetCore.Mvc.Testing"
575567

576568
# 使用别名
@@ -602,10 +594,10 @@ jobs:
602594
run: dotnet tool install -g dotnet-execute
603595

604596
- name: Run Unit Tests
605-
run: dotnet-exec tests/unit-tests.cs --test --reference "nuget:FluentAssertions"
597+
run: dotnet-exec test tests/unit-tests.cs --reference "nuget:FluentAssertions"
606598

607599
- name: Run Integration Tests
608-
run: dotnet-exec tests/integration-tests.cs --profile integration-tests
600+
run: dotnet-exec test tests/integration-tests.cs --profile integration-tests
609601

610602
- name: Generate Test Report
611603
run: dotnet-exec tests/test-reporter.cs --output ./test-results.xml
@@ -652,26 +644,26 @@ TestReporter.GenerateReport("./test-results.json");
652644

653645
```sh
654646
# 测试发现问题
655-
dotnet-exec test.cs --test --verbose
647+
dotnet-exec test test.cs --verbose
656648

657649
# 并行测试问题
658-
dotnet-exec test.cs --test --disable-parallelization
650+
dotnet-exec test test.cs --disable-parallelization
659651

660652
# 依赖冲突
661-
dotnet-exec test.cs --test --show-dependency-conflicts
653+
dotnet-exec test test.cs --show-dependency-conflicts
662654
```
663655

664656
### 调试测试
665657

666658
```sh
667659
# 启用详细输出
668-
dotnet-exec test.cs --test --verbose
660+
dotnet-exec test test.cs --debug
669661

670662
# 单独运行特定测试
671-
dotnet-exec test.cs --test --filter "TestClassName.TestMethodName"
663+
dotnet-exec test test.cs --filter "TestClassName.TestMethodName"
672664

673665
# 调试模式
674-
dotnet-exec test.cs --test --configuration Debug --wait-for-debugger
666+
dotnet-exec test test.cs --configuration Debug
675667
```
676668

677669
这个全面的测试指南展示了如何使用 dotnet-exec 进行各种测试场景,从简单的单元测试到复杂的集成测试和性能基准测试。

0 commit comments

Comments
 (0)