公司动态
Boxed.DotnetNewTest:.NET模板测试自动化的终极解决方案
Boxed.DotnetNewTest.NET模板测试自动化的终极解决方案【免费下载链接】Framework.NET Core Extensions and Helper NuGet packages.项目地址: https://gitcode.com/gh_mirrors/framework8/FrameworkBoxed.DotnetNewTest是一个专为dotnet new项目模板打造的单元测试框架它能帮助开发者轻松实现模板测试的自动化显著提升.NET项目模板的质量与可靠性。 核心功能一站式模板测试体验Boxed.DotnetNewTest提供了完整的模板测试生命周期管理主要功能包括1️⃣ 模板安装与项目创建从指定目录安装基于dotnet new的项目模板在临时目录中快速创建模板项目避免干扰开发环境2️⃣ 构建流程自动化自动执行dotnet restore命令验证依赖项配置运行dotnet build和dotnet publish命令检查项目构建完整性3️⃣ 应用测试支持对ASP.NET Core项目模板提供dotnet run支持内置HttpClient可直接调用应用接口进行功能测试 快速上手简单三步实现模板测试第一步安装Boxed.DotnetNewTest通过NuGet安装Boxed.DotnetNewTest包为你的测试项目添加依赖Install-Package Boxed.DotnetNewTest第二步编写测试代码创建测试类使用Boxed.DotnetNewTest的API编写测试用例。以下是一个基本示例public class ApiTemplateTest { public ApiTemplateTest() DotnetNew.InstallApiTemplateTest(ApiTemplate.sln).Wait(); [Fact] public async Task Run_DefaultArguments_IsSuccessful() { using (var tempDirectory TempDirectory.NewTempDirectory()) { var project await tempDirectory.DotnetNew(api, DefaultArguments); await project.DotnetRestore(); await project.DotnetBuild(); await project.DotnetRun( Source\DefaultArguments, async (httpClient, httpsClient) { var httpResponse await httpsClient.GetAsync(status); Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode); }); } } }第三步运行测试使用你喜欢的测试运行器执行测试Boxed.DotnetNewTest会自动处理模板安装、项目创建、构建和测试的全过程。 高级用法参数化测试与自定义配置参数化测试通过[Theory]和[InlineData]特性可以轻松实现多参数组合测试[Theory] [InlineData(StatusEndpointOn, status-endpointtrue)] [InlineData(StatusEndpointOff, status-endpointfalse)] public async Task RestoreAndBuild_CustomArguments_IsSuccessful(string name, params string[] arguments) { using (var tempDirectory TempDirectory.NewTempDirectory()) { var dictionary arguments .Select(x x.Split(, StringSplitOptions.RemoveEmptyEntries)) .ToDictionary(x x.First(), x x.Last()); var project await tempDirectory.DotnetNew(api, name, dictionary); await project.DotnetRestore(); await project.DotnetBuild(); } }临时目录管理Boxed.DotnetNewTest提供了灵活的临时目录管理功能确保测试环境的隔离与清洁TempDirectory.NewTempDirectory()创建标准临时目录TempDirectory.NewShortTempDirectory()创建短路径临时目录解决MSBuild 256字符路径限制问题 项目结构与核心组件Boxed.DotnetNewTest的核心代码位于Source/Boxed.DotnetNewTest/目录主要组件包括DotnetNew模板安装与项目创建的核心类TempDirectory临时目录管理实现IAsyncDisposable接口Project项目对象提供构建、运行等操作方法ProjectExtensions扩展方法类提供DotnetRestore、DotnetBuild等便捷方法 官方文档与资源详细文档Documentation/Boxed.DotnetNewTest.md源代码Source/Boxed.DotnetNewTest/测试示例Tests/ 如何贡献如果你对Boxed.DotnetNewTest感兴趣欢迎通过以下方式贡献克隆仓库git clone https://gitcode.com/gh_mirrors/framework8/Framework创建分支git checkout -b feature/your-feature提交更改git commit -m Add your feature推送分支git push origin feature/your-feature创建Pull RequestBoxed.DotnetNewTest为.NET模板开发提供了强大的测试支持让模板质量保障变得简单高效。无论是个人开发者还是企业团队都能从中受益打造更可靠的.NET项目模板。【免费下载链接】Framework.NET Core Extensions and Helper NuGet packages.项目地址: https://gitcode.com/gh_mirrors/framework8/Framework创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考