SKTestSession
The controls and environment configuration you use to test StoreKit transactions in Xcode.
Declaration
class SKTestSessionOverview
This class controls the settings that the server uses when it processes transactions. Run tests that reconfigure the environment serially, not concurrently, to avoid overwriting each other’s environment settings.
The test environment creates an SKTestTransaction instance each time your test code calls any method of SKTestSession that affects in-app purchases, including:
You can manage the transactions in the test environment. To get a list of all transactions in the test environment, call allTransactions(). To delete a single transaction, call deleteTransaction(identifier:). To delete all the transactions, call clearTransactions().
Before automating a test session with SKTestSession, you must create a StoreKit configuration file. For more information, see Setting up StoreKit Testing in Xcode and init(configurationFileNamed:). Set disableDialogs to true to run tests without showing test environment UI.
Topics
Initializing test sessions
Configuring the test environment
Managing transactions in the test environment
Forcing failed transactions
Testing interrupted purchases
Testing Ask To Buy transactions
Testing subscription renewals
timeRateSKTestSession.TimeRateenableAutoRenewForTransaction(identifier:)disableAutoRenewForTransaction(identifier:)forceRenewalOfSubscription(productIdentifier:)expireSubscription(productIdentifier:)
Testing billing retry and grace period
Testing price increase consent
requestPriceIncreaseConsentForTransaction(identifier:)consentToPriceIncreaseForTransaction(identifier:)declinePriceIncreaseForTransaction(identifier:)