Storekit configuration file for UITest
Asked Answered
E

1

6

I created Configuration.storekit file, and it work for Run on ios simulator. But when i'm trying to run UITest, it always fails on initing SKTestSession(configurationFileNamed: "Configuration") with error:

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

Here is my code

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
        
        *****
        
    }
}

If i'm trying to @testable import MyProject it fails with another errors:

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

I even tried to add Target Membership for Configuration.storekit file in MyProjectUITests target.

Can anyone say, how could I init SKTestSession(configurationFileNamed: "Configuration") without getting errors?

Eckhardt answered 25/9, 2020 at 8:34 Comment(1)
Problem was solved after xCode update =)Eckhardt
H
3

To solve the "File Not Found" I added the .storekit file to the Test-Bundle.

  • Make sure you use the right XCode Version, as @Dmitrii mentioned. I'm currently at 12.3
  • In addition, make sure to add the .storekit to the test-bundle:
    • Open the .xcodeproj file
    • Click on your Test-target
    • Go to tab "Build Phases"
    • At "Copy Bundle Resources" add the .storekit file

Not sure, if these are all the required steps to get it running. At least the SKTestSession finds the configuration file now.

Honourable answered 18/12, 2020 at 21:35 Comment(1)
It was enough for me to add the file to the Copy Bundle Resources phase; I didn't have to add ".storekit" to the name passed to SKTestSession(configurationFileNamed:).Argentiferous

© 2022 - 2024 — McMap. All rights reserved.