
新增.gitignore、Podfile和Podfile.lock文件以管理项目依赖,添加README.md文件提供项目简介和安装步骤,创建NIMSessionManager、ClientConfig、LogManager和NetworkManager等管理类以支持网络请求和日志记录功能,更新AppDelegate和ContentView以集成NIM SDK和实现用户登录功能。
69 lines
2.3 KiB
Swift
69 lines
2.3 KiB
Swift
//
|
|
// yanaAPITests.swift
|
|
// yanaAPITests
|
|
//
|
|
// Created by P on 2025/5/27.
|
|
//
|
|
|
|
import XCTest
|
|
@testable import yana
|
|
|
|
final class yanaAPITests: XCTestCase {
|
|
|
|
override func setUpWithError() throws {
|
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
}
|
|
|
|
override func tearDownWithError() throws {
|
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
}
|
|
|
|
func testExample() throws {
|
|
// This is an example of a functional test case.
|
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
|
// Any test you write for XCTest can be annotated as throws and async.
|
|
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
|
|
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
|
|
}
|
|
|
|
func testPerformanceExample() throws {
|
|
// This is an example of a performance test case.
|
|
measure {
|
|
// Put the code you want to measure the time of here.
|
|
}
|
|
}
|
|
|
|
func testClientInit_Success() {
|
|
let expectation = self.expectation(description: "clientInit success")
|
|
API.clientInit { result in
|
|
switch result {
|
|
case .success(let data):
|
|
XCTAssertNotNil(data)
|
|
// 可根据实际返回内容进一步断言
|
|
case .failure(let error):
|
|
XCTFail("Expected success, got error: \(error)")
|
|
}
|
|
expectation.fulfill()
|
|
}
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
}
|
|
|
|
func testClientInit_Failure() {
|
|
// 可通过mock或断网等方式测试失败场景
|
|
// 这里只做结构示例
|
|
let expectation = self.expectation(description: "clientInit failure")
|
|
// 假设API支持注入baseURL或mock
|
|
API.clientInit { result in
|
|
switch result {
|
|
case .success(_):
|
|
// 若期望失败则此处应fail
|
|
XCTFail("Expected failure, got success")
|
|
case .failure(let error):
|
|
XCTAssertNotNil(error)
|
|
}
|
|
expectation.fulfill()
|
|
}
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
}
|
|
}
|