【问题标题】:Storekit configuration file for UITestUITest 的 Storekit 配置文件
【发布时间】:2020-09-25 08:34:53
【问题描述】:

我创建了Configuration.storekit 文件,它适用于在 ios 模拟器上运行。 但是当我尝试运行 UITest 时,它总是在初始化 SKTestSession(configurationFileNamed: "Configuration") 时失败并出现错误:

caught error: "Error Domain=SKTestErrorDomain Code=4 "File not found" UserInfo={NSLocalizedDescription=File not found}"

这是我的代码

import XCTest
import StoreKitTest

class MyProjectUITests: XCTestCase {

    override func setUpWithError() throws {
        continueAfterFailure = false
    }

    override func tearDownWithError() throws {
        
    }

    func testExample() throws {
        if #available(iOS 14.0, *) {
            let session = try SKTestSession(configurationFileNamed: "Configuration")
            session.disableDialogs = true
            session.clearTransactions()
        }
        // UI tests
        
        *****
        
    }
}

如果我尝试 @testable import MyProject 它会失败并出现另一个错误:

Missing required modules: 'Amplitude', 'FBSDKCoreKit', 'Firebase'

我什至尝试在 MyProjectUITests 目标中为 Configuration.storekit 文件添加 Target Membership

谁能说,我怎样才能初始化 SKTestSession(configurationFileNamed: "Configuration") 而不会出错?

【问题讨论】:

  • xCode 更新后问题已解决 =)

标签: swift uitest storekittest


【解决方案1】:

为了解决“找不到文件”的问题,我将 .storekit 文件添加到了 Test-Bundle。

  • 确保使用正确的 XCode 版本,正如 @Dmitrii 所提到的。我现在是 12.3
  • 此外,确保将.storekit 添加到测试包中:
    • 打开.xcodeproj文件
    • 点击您的测试目标
    • 转到“构建阶段”选项卡
    • 在“复制捆绑资源”中添加 .storekit 文件

不确定,如果这些是使其运行所需的所有步骤。 至少SKTestSession 现在找到了配置文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-25
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-24
    • 1970-01-01
    • 2016-10-02
    相关资源
    最近更新 更多