Storekit configuration file for UITest

1.3k Views Asked by At

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?

1

There are 1 best solutions below

1
On

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.