实例介绍
本示例项目展现了如何进行ASP.NET Core Web应用程序的集成测试,特别是利用了Minimal APIs特性。该系统测试样本实现了一个简单的Todo列表应用,采用了以下技术:
- Minimal APIs
- EFCore与SQLite
- Razor Pages
- TypeScript
此外,测试中还展示了如何使用以下开源库和技术:
coverlet HttpClientFactory HttpClient Interception Playwright ReportGenerator Shouldly WebApplicationFactory<T> xunit xunit Logging要在本地调试应用程序(脱离集成测试),您需要创建一个GitHub OAuth应用以获取OAuth用户认证所需的密钥。
构建和测试应用程序需要安装Git和.NET SDK(版本8.0.100或更高)。本地构建和测试应用,请在终端/命令行运行以下命令集:
git clone https://example.com/martincostello/dotnet-minimal-api-integration-testing.git cd dotnet-minimal-api-integration-testing ./build.ps1【实例截图】
【核心代码】
文件清单
└── dotnet-minimal-api-integration-testing-306f11c3dda1c6388306b99e4626276138ed4c1c
├── build.ps1
├── CODE_OF_CONDUCT.md
├── Directory.Build.props
├── global.json
├── LICENSE
├── NuGet.config
├── omnisharp.json
├── README.md
├── SECURITY.md
├── src
│ └── TodoApp
│ ├── ApiEndpoints.cs
│ ├── appsettings.Development.json
│ ├── appsettings.json
│ ├── AuthenticationEndpoints.cs
│ ├── Data
│ │ ├── ITodoRepository.cs
│ │ ├── TodoContext.cs
│ │ ├── TodoItem.cs
│ │ └── TodoRepository.cs
│ ├── Extensions
│ │ └── DbSetExtensions.cs
│ ├── Models
│ │ ├── CreatedTodoItemModel.cs
│ │ ├── CreateTodoItemModel.cs
│ │ ├── TodoItemModel.cs
│ │ └── TodoListViewModel.cs
│ ├── package.json
│ ├── package-lock.json
│ ├── Pages
│ │ ├── Home
│ │ │ ├── Index.cshtml
│ │ │ └── Index.cshtml.cs
│ │ ├── Shared
│ │ │ ├── Error.cshtml
│ │ │ ├── Error.cshtml.cs
│ │ │ └── _Layout.cshtml
│ │ ├── _ViewImports.cshtml
│ │ └── _ViewStart.cshtml
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── scripts
│ │ └── ts
│ │ ├── client
│ │ │ └── TodoClient.ts
│ │ ├── main.ts
│ │ ├── models
│ │ │ ├── TodoItem.ts
│ │ │ └── TodoList.ts
│ │ └── view
│ │ ├── Classes.ts
│ │ ├── Elements.ts
│ │ ├── Selectors.ts
│ │ ├── TodoApp.test.ts
│ │ ├── TodoApp.ts
│ │ └── TodoElement.ts
│ ├── Services
│ │ ├── ITodoService.cs
│ │ └── TodoService.cs
│ ├── TodoApp.csproj
│ ├── tsconfig.json
│ ├── webpack.config.js
│ └── wwwroot
│ ├── css
│ │ └── site.css
│ ├── favicon.ico
│ └── swagger-ui
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── index.html
│ ├── swagger-ui-bundle.js
│ ├── swagger-ui-bundle.js.map
│ ├── swagger-ui.css
│ ├── swagger-ui.css.map
│ ├── swagger-ui-standalone-preset.js
│ └── swagger-ui-standalone-preset.js.map
├── startvs.cmd
├── startvscode.cmd
├── tests
│ └── TodoApp.Tests
│ ├── ApiTests.cs
│ ├── BrowserFixture.cs
│ ├── BrowserFixtureOptions.cs
│ ├── BrowserStackLocalOptions.cs
│ ├── BrowserStackLocalService.cs
│ ├── HttpRequestInterceptionFilter.cs
│ ├── HttpServerCollection.cs
│ ├── HttpServerFixture.cs
│ ├── localhost-dev.pfx
│ ├── LoopbackOAuthEvents.cs
│ ├── oauth-http-bundle.json
│ ├── RemoteAuthorizationEventsFilter.cs
│ ├── ShouldlyTaskExtensions.cs
│ ├── TodoAppCollection.cs
│ ├── TodoAppFixture.cs
│ ├── TodoApp.Tests.csproj
│ ├── TodoPage.cs
│ ├── UITests.cs
│ └── xunit.runner.json
├── TodoApp.ruleset
└── TodoApp.sln
21 directories, 82 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论