I am writing unit tests that change the country by setting the .storefront
property of SKTestSession
to different country codes. I have made sure that the country codes I am using are indeed valid based on ISO 3166-1 alpha-3 region code standards.
My default storefront in the StoreKit Configuration file is "USA"
but in the unit test, I set it to say "IND
" and it runs my test. In the production code, when I print await Storefront.current?.countryCode
, I indeed get "IND"
as expected. Now when I change the value to say "RUS"
by assigning it to the SKTestSession
instance, the printed value in production code is still "IND"
from the previous assignment.
If I call .resetToDefaultState()
on the session after first test passes with "IND"
, it defaults to "USA"
but when I set it to "RUS"
in my test after it, it stays on "USA"
.
Basically the value does not change after the first change and calling reset resets it to configuration file default but reassigning a new value has no effect on Storefront.
What am I doing wrong?
Btw, I have tested with both XCTest and Swift Testing but the testing framework has nothing to do with this issue.
I am on Xcode 16, macOS 15, Swift 6