首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XCUITest与TestRail的集成

XCUITest与TestRail的集成
EN

Stack Overflow用户
提问于 2018-07-31 22:24:01
回答 2查看 1.6K关注 0票数 4

目前正致力于将我的UITest运行结果集成到TestRail中,所以每次测试运行之后,它都会将我的测试标记为testrail中的Pass\Fail。

我的想法是:

  1. 在CI中创建一个“预构建”脚本,它将在testrail中创建一个测试运行。
  2. 在自动化执行过程中,在test tearDown()中获取测试结果(如果测试失败与否),将其全部保存到json文件中。-,这是第一个问题,如果测试失败,我如何获得?
  3. 完成所有测试后,运行一个“后期构建”脚本来更新json文件,并将请求发送到测试轨(这将标志着通过\ file测试)。

任何人谁已经做过这方面的工作,这听起来对你合适吗?有什么建议吗?

测试示例:

代码语言:javascript
复制
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
    }
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-10-03 00:36:11

我就是这样实现的。首先,我的CI中有预构建脚本,它将在TestRail中创建新的测试运行。然后,UITestObserver将向TR发送API以更新状态。

我增加了一个新的类:

代码语言:javascript
复制
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添加了以下一行:

代码语言:javascript
复制
XCTestObservationCenter.shared.addTestObserver(UITestObserver())

并实现了发送实际请求以更新状态的函数postTestRailAddResultAPI。我的所有测试现在都有存储TestRail TestCase number值的TestRail TestCase number,它就是这样知道要更新哪个TCs的。

票数 5
EN

Stack Overflow用户

发布于 2018-09-28 05:49:07

我就是这么做的

  1. 使用fastlane的扫描插件运行测试
  2. 生成junit格式结果
  3. 解析xml并获取每个测试的结果。
  4. 将其发布到我们的测试用例管理工具中。

请与我们分享您的解决方案。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51622950

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档