目前正致力于将我的UITest运行结果集成到TestRail中,所以每次测试运行之后,它都会将我的测试标记为testrail中的Pass\Fail。
我的想法是:
任何人谁已经做过这方面的工作,这听起来对你合适吗?有什么建议吗?
测试示例:
import XCTest
class MyUITests: XCTestCase {
override func setUp() {
super.setUp()
continueAfterFailure = false
appEntry.app.launch()
dismissSystemAlerts()
}
override func tearDown() {
super.tearDown()
}
func test_Elements() {
// MARK: Sample test
// my test actions are here
}
}发布于 2018-10-03 00:36:11
我就是这样实现的。首先,我的CI中有预构建脚本,它将在TestRail中创建新的测试运行。然后,UITestObserver将向TR发送API以更新状态。
我增加了一个新的类:
import Foundation
import XCTest
class UITestObserver: NSObject, XCTestObservation {
// Handle Test Case Failure
public func testCase(_ testCase: XCTestCase,
didFailWithDescription description: String,
inFile filePath: String?,
atLine lineNumber: Int) {
var testCaseId: [String] = []
if let MyTestCaseID = testCase as? BaseTest { testCaseId = MyTestCaseID.inegrateTestRailId() }
if testCaseId != ["NA"] {
postTestRailAddResultAPI(for: testCase, testCaseId: testCaseId, description: description)
}
}
// Handle Test Case Pass
public func testCaseDidFinish(_ testCase: XCTestCase) {
let testRun = testCase.testRun!
let verb = testRun.hasSucceeded
var testCaseId: [String] = []
if let MyTestCaseID = testCase as? BaseTest { testCaseId = MyTestCaseID.inegrateTestRailId() }
if verb == true && testCaseId != ["NA"] {
postTestRailAddResultAPI(for: testCase, testCaseId: testCaseId, description: "PASS")
}
}在BaseTest中,setUp添加了以下一行:
XCTestObservationCenter.shared.addTestObserver(UITestObserver())并实现了发送实际请求以更新状态的函数postTestRailAddResultAPI。我的所有测试现在都有存储TestRail TestCase number值的TestRail TestCase number,它就是这样知道要更新哪个TCs的。
发布于 2018-09-28 05:49:07
我就是这么做的
请与我们分享您的解决方案。
https://stackoverflow.com/questions/51622950
复制相似问题