RPC远程过程调用,二进制封装,提供高吞吐低延迟的高性能RPC框架
大石头 authored at 2022-08-10 13:26:19
7.62 KiB
NewLife.Remoting
# 单元测试与集成测试覆盖状态 > 最后更新: 2025-07-02 ## 测试概况 | 指标 | 数值 | |--------|------| | 总测试数 | 465 | | 通过 | 465 | | 失败 | 0 | | 跳过 | 2 | | 单元测试 | ~409 | | 集成测试 | ~56 | | 测试框架 | xUnit 2.9.3 | | 目标框架 | net10.0 | ## NewLife.Remoting 测试覆盖 | 源文件 / 类 | 测试文件 | 测试数量 | 状态 | |-------------|---------|---------|------| | ApiAttribute | ApiAttributeTests.cs | 4 | ✅ 通过 | | ApiAction | ApiActionTests.cs | 12 | ✅ 通过 | | ApiMessage | ApiMessageTests.cs | 6 | ✅ 通过 | | ApiHost | ApiHostTests.cs | 7 | ✅ 通过 | | ApiServer | ApiServerTests.cs | 已有 | ✅ 通过 | | ApiClient | ApiClientTests.cs | 已有 | ✅ 通过 | | ApiHandler (IApiHandler) | ApiHandlerTests.cs | 已有 | ✅ 通过 | | ApiManager (IApiManager) | ApiManagerTests.cs | 12 | ✅ 通过 | | ApiReceivedEventArgs | ApiReceivedEventArgsTests.cs | 2 | ✅ 通过 | | JsonEncoder | JsonEncoderTests.cs + JsonEncoderExtendedTests.cs | 10+12 | ✅ 通过 | | HttpEncoder | HttpEncoderTests.cs | ~20 | ✅ 通过 | | HttpCodec | HttpCodecTests.cs | 3 | ✅ 通过 | | HttpMessage | HttpMessageTests.cs | 已有 | ✅ 通过 | | WebSocketClientCodec / WebSocketServerCodec | WebSocketCodecTests.cs | 4 | ✅ 通过 | | ClientBase | ClientBaseTests.cs | 11 | ✅ 通过 | | ClientPoolCluster / ClientSingleCluster | ClusterTests.cs | ~18 | ✅ 通过 | | ControllerContext | ControllerContextTests.cs | 5 | ✅ 通过 | | IActionFilter | ActionFilterTests.cs | 3 | ✅ 通过 | | Upgrade | UpgradeTests.cs | 9 | ✅ 通过 | | ServerTimeProvider | ServerTimeProviderTests.cs | 3 | ✅ 通过 | | CommandSession | CommandSessionTests.cs | 4 | ✅ 通过 | | SessionManager | SessionManagerTests.cs | 已有 | ✅ 通过 | | RemotingExtensions (BuildCode) | RemotingExtensionsTests.cs | 9 | ✅ 通过 | | Features / LoginStatus / UpdateModes | ModelTests.cs | ~20 | ✅ 通过 | | EventModel / CommandInModel / CommandEventArgs | ModelTests.cs | 含上 | ✅ 通过 | | LoginEventArgs / LogoutResponse / UpgradeInfo | ModelTests.cs | 含上 | ✅ 通过 | | LoginRequest / LoginResponse | MoreModelTests.cs | 8 | ✅ 通过 | | PingRequest / PingResponse | MoreModelTests.cs | 6 | ✅ 通过 | | CommandModel / CommandReplyModel | MoreModelTests.cs | 4 | ✅ 通过 | | DeviceContext | MoreModelTests.cs + DeviceServiceTests.cs | 4 | ✅ 通过 | | CommandClient (ICommandClient) | CommandClientTests.cs | 已有 | ✅ 通过 | | ApiException / ApiCode | BasicTest.cs | 4 | ✅ 通过 | ### 集成测试 | 测试场景 | 测试文件 | 测试数量 | 状态 | |---------|---------|---------|------| | ApiServer + ApiClient 端到端 (TCP) | ApiServerClientIntegrationTests.cs | 已有 | ✅ 通过 | | Api服务端降级重连 | ApiDownTests.cs | 已有 | ✅ 通过 | | OwnerPacket生命周期 | OwnerPacketLifecycleTests.cs | 已有 | ✅ 通过 | | HTTP 模式端到端 | HttpIntegrationTests.cs | 10 | ✅ 通过 | | 重试策略 (IRetryPolicy) | RetryPolicyIntegrationTests.cs | 6 | ✅ 通过 | | Action过滤器管线 (IActionFilter) | ActionFilterIntegrationTests.cs | 5 | ✅ 通过 | | 集群连接池与故障转移 | ClusterIntegrationTests.cs | 8 | ✅ 通过 | | 超时/单向/非复用/慢追踪 | TimeoutOneWayIntegrationTests.cs | 8 | ✅ 通过 | | Token注入与登录流程 | TokenLoginIntegrationTests.cs | 8 | ✅ 通过 | | 多控制器路由与异步方法 | MultiControllerRoutingTests.cs | 11 | ✅ 通过 | ### 未覆盖说明 | 类 | 原因 | |----|------| | WsClient | 需要WebSocket服务端配合,属集成测试范畴 | | WsChannel / WsChannelCore | 需要WebSocket连接,属集成测试范畴 | | AliyunClient | 需要阿里云AK/SK,属外部依赖集成测试 | | ApiHttpServer | 内部服务器类,由ApiServer组合使用,间接测试 | | ApiNetServer | 内部服务器类,由ApiServer组合使用,间接测试 | | 纯接口文件 (IApi, IEncoder, ICluster等) | 接口无需直接测试,由实现类覆盖 | ## NewLife.Remoting.Extensions 测试覆盖 | 源文件 / 类 | 测试文件 | 测试数量 | 状态 | |-------------|---------|---------|------| | TokenService | TokenServiceTests.cs | 8 | ✅ 通过 | | TokenInModel | TokenInModelTests.cs | 2 | ✅ 通过 | | ApiFilterAttribute | ApiFilterAttributeTests.cs | 7 | ✅ 通过 | | WebHelper | WebHelperTests.cs | 8 | ✅ 通过 | | RemotingExtensions (DI) | RemotingDITests.cs | 7 | ✅ 通过 | ### 未覆盖说明 | 类 | 原因 | |----|------| | BaseController | 需ASP.NET Core TestServer完整管线,控制器测试属集成测试 | | BaseDeviceController | 同上,需设备服务和XCode实体支持 | | BaseOAuthController | 同上,需OAuth认证管线 | | DefaultDeviceService | 需XCode数据库连接,属集成测试 | | WsCommandSession | 需WebSocket连接实例,属集成测试 | | InterfaceModelBinder | 需ModelBindingContext,属集成测试 | ## 测试文件清单 ``` XUnitTest/ ├── ActionFilterIntegrationTests.cs (新增-集成) ├── ActionFilterTests.cs (新增) ├── ApiActionTests.cs (新增) ├── ApiAttributeTests.cs (新增) ├── ApiClientTests.cs (已有) ├── ApiDownTests.cs (已有) ├── ApiFilterAttributeTests.cs (新增) ├── ApiHandlerTests.cs (已有) ├── ApiHelperTest.cs (已有) ├── ApiHostTests.cs (新增) ├── ApiHttpClientTests.cs (已有) ├── ApiManagerTests.cs (新增) ├── ApiMessageTests.cs (新增) ├── ApiReceivedEventArgsTests.cs (新增) ├── ApiServerClientIntegrationTests.cs (已有) ├── ApiServerTests.cs (已有) ├── ApiTest.cs (已有) ├── BasicTest.cs (补充) ├── ClientBaseTests.cs (补充) ├── ClusterIntegrationTests.cs (新增-集成) ├── ClusterTests.cs (新增) ├── CommandClientTests.cs (已有) ├── CommandSessionTests.cs (新增) ├── ControllerContextTests.cs (新增) ├── DeviceServiceTests.cs (已有) ├── HttpCodecTests.cs (新增) ├── HttpEncoderTests.cs (新增) ├── HttpIntegrationTests.cs (新增-集成) ├── HttpMessageTests.cs (已有) ├── JsonEncoderExtendedTests.cs (新增) ├── JsonEncoderTests.cs (已有) ├── ModelTests.cs (新增) ├── MoreModelTests.cs (新增) ├── MultiControllerRoutingTests.cs (新增-集成) ├── OwnerPacketLifecycleTests.cs (已有) ├── RemotingDITests.cs (新增) ├── RemotingExtensionsTests.cs (新增) ├── RetryPolicyIntegrationTests.cs (新增-集成) ├── ServerTimeProviderTests.cs (新增) ├── SessionManagerTests.cs (已有) ├── TimeoutOneWayIntegrationTests.cs (新增-集成) ├── TokenInModelTests.cs (新增) ├── TokenLoginIntegrationTests.cs (新增-集成) ├── TokenServiceTests.cs (新增) ├── UpgradeTests.cs (新增) ├── WebHelperTests.cs (新增) └── WebSocketCodecTests.cs (新增) ``` ## 运行方式 ```bash # 运行全部测试 dotnet test XUnitTest/XUnitTest.csproj # 运行指定类的测试 dotnet test XUnitTest/XUnitTest.csproj --filter "FullyQualifiedName~ApiManagerTests" # 带详细输出 dotnet test XUnitTest/XUnitTest.csproj -v d ```