bag
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// 测试工程的运行调试入口(非测试用例)。
|
||||
//
|
||||
// 用法:
|
||||
// dotnet run --project tests/Yh.SchClass.OpenApi.Tests # 一键跑通全部 20 个端点
|
||||
// dotnet run --project tests/Yh.SchClass.OpenApi.Tests -- --only=OAStu
|
||||
// dotnet run --project tests/Yh.SchClass.DebugTool -- --list # 端点名清单见 DebugTool
|
||||
//
|
||||
// 地址优先级同 SchClassLiveDebug:环境变量 YH_SCHCLASS_DEBUG_* → appsettings.json → 内置默认。
|
||||
// 在 IDE 里直接 F5 调试本项目即可进入这里(在 Main 内打断点)。
|
||||
//
|
||||
// 注意:csproj 已设 GenerateProgramFile=false(关掉 Test SDK 自动 Main),dotnet test 不受影响。
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Yh.SchClass.OpenApi.Tests;
|
||||
|
||||
public static class DebugMain
|
||||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
string? only = null;
|
||||
foreach (var arg in args)
|
||||
{
|
||||
if (arg.StartsWith("--only=", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
only = arg[7..].Trim();
|
||||
}
|
||||
else if (arg.Equals("--off", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Console.WriteLine("跳过联调:--off(同 YH_SCHCLASS_DEBUG_OFF=1)");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (Environment.GetEnvironmentVariable(SchClassLiveDebug.OffVar) is "1" or "true")
|
||||
{
|
||||
Console.WriteLine("跳过联调:已设置 " + SchClassLiveDebug.OffVar + "=1(清除该变量即可恢复联调)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Console.WriteLine("== SchClass OpenAPI 测试工程调试入口 ==");
|
||||
var failures = await SchClassLiveDebug.RunAllAsync(Console.WriteLine, only);
|
||||
if (failures.Count == 0)
|
||||
{
|
||||
Console.WriteLine("全部通过 ✅");
|
||||
return 0;
|
||||
}
|
||||
Console.WriteLine($"失败 {failures.Count} 个:{string.Join(", ", failures)}");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user