---
title: SKTestSession
framework: storekittest
role: symbol
role_heading: Class
path: storekittest/sktestsession
---

# SKTestSession

The controls and environment configuration you use to test StoreKit transactions in Xcode.

## Declaration

```swift
class SKTestSession
```

## Overview

Overview 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. note: There’s a single instance of the test environment. All SKTestSession instances control the same test environment. The test environment creates an SKTestTransaction instance each time your test code calls any method of SKTestSession that affects in-app purchases, including: buyProduct(productIdentifier:) refundTransaction(identifier:) enableAutoRenewForTransaction(identifier:) disableAutoRenewForTransaction(identifier:) forceRenewalOfSubscription(productIdentifier:) expireSubscription(productIdentifier:) approveAskToBuyTransaction(identifier:) declineAskToBuyTransaction(identifier:) resolveIssueForTransaction(identifier:) 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

- [init(configurationFileNamed:)](storekittest/sktestsession/init(configurationfilenamed:).md)
- [init(contentsOf:)](storekittest/sktestsession/init(contentsof:).md)
- [resetToDefaultState()](storekittest/sktestsession/resettodefaultstate().md)

### Configuring the test environment

- [storefront](storekittest/sktestsession/storefront.md)
- [locale](storekittest/sktestsession/locale.md)
- [disableDialogs](storekittest/sktestsession/disabledialogs.md)

### Managing transactions in the test environment

- [allTransactions()](storekittest/sktestsession/alltransactions().md)
- [deleteTransaction(identifier:)](storekittest/sktestsession/deletetransaction(identifier:).md)
- [clearTransactions()](storekittest/sktestsession/cleartransactions().md)

### Forcing failed transactions

- [failTransactionsEnabled](storekittest/sktestsession/failtransactionsenabled.md)
- [failureError](storekittest/sktestsession/failureerror.md)

### Testing interrupted purchases

- [interruptedPurchasesEnabled](storekittest/sktestsession/interruptedpurchasesenabled.md)
- [resolveIssueForTransaction(identifier:)](storekittest/sktestsession/resolveissuefortransaction(identifier:).md)

### Testing Ask To Buy transactions

- [askToBuyEnabled](storekittest/sktestsession/asktobuyenabled.md)
- [approveAskToBuyTransaction(identifier:)](storekittest/sktestsession/approveasktobuytransaction(identifier:).md)
- [declineAskToBuyTransaction(identifier:)](storekittest/sktestsession/declineasktobuytransaction(identifier:).md)

### Testing subscription renewals

- [timeRate](storekittest/sktestsession/timerate-swift.property.md)
- [SKTestSession.TimeRate](storekittest/sktestsession/timerate-swift.enum.md)
- [enableAutoRenewForTransaction(identifier:)](storekittest/sktestsession/enableautorenewfortransaction(identifier:).md)
- [disableAutoRenewForTransaction(identifier:)](storekittest/sktestsession/disableautorenewfortransaction(identifier:).md)
- [forceRenewalOfSubscription(productIdentifier:)](storekittest/sktestsession/forcerenewalofsubscription(productidentifier:).md)
- [expireSubscription(productIdentifier:)](storekittest/sktestsession/expiresubscription(productidentifier:).md)

### Testing billing retry and grace period

- [billingGracePeriodIsEnabled](storekittest/sktestsession/billinggraceperiodisenabled.md)
- [shouldEnterBillingRetryOnRenewal](storekittest/sktestsession/shouldenterbillingretryonrenewal.md)
- [resolveIssueForTransaction(identifier:)](storekittest/sktestsession/resolveissuefortransaction(identifier:).md)

### Testing price increase consent

- [requestPriceIncreaseConsentForTransaction(identifier:)](storekittest/sktestsession/requestpriceincreaseconsentfortransaction(identifier:).md)
- [consentToPriceIncreaseForTransaction(identifier:)](storekittest/sktestsession/consenttopriceincreasefortransaction(identifier:).md)
- [declinePriceIncreaseForTransaction(identifier:)](storekittest/sktestsession/declinepriceincreasefortransaction(identifier:).md)

### Testing externally performed transactions

- [buyProduct(productIdentifier:)](storekittest/sktestsession/buyproduct(productidentifier:).md)
- [refundTransaction(identifier:)](storekittest/sktestsession/refundtransaction(identifier:).md)

### Instance Methods

- [buyProduct(identifier:options:)](storekittest/sktestsession/buyproduct(identifier:options:).md)
- [setSimulatedError(_:forAPI:)](storekittest/sktestsession/setsimulatederror(_:forapi:).md)
- [simulatedError(forAPI:)](storekittest/sktestsession/simulatederror(forapi:).md)

### Initializers

- [init(contentsOfURL:)](storekittest/sktestsession/init(contentsofurl:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### StoreKit transaction testing

- [Setting up StoreKit Testing in Xcode](xcode/setting-up-storekit-testing-in-xcode.md)
- [SKTestTransaction](storekittest/sktesttransaction.md)
