Created
August 1, 2024 16:15
-
-
Save 4np/fa4eba3412d160f39be8352f5c80b557 to your computer and use it in GitHub Desktop.
Run tests using a particular locale and / or language (useful for SPM projects)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
class SomeTests: XCTestCase { | |
override class func setUp() { | |
super.setUp() | |
UserDefaults.standard.set("en_US", forKey: "AppleLocale") | |
UserDefaults.standard.set(["en_US"], forKey: "AppleLanguages") | |
UserDefaults.standard.synchronize() | |
} | |
override class func tearDown() { | |
super.tearDown() | |
UserDefaults.standard.removeObject(forKey: "AppleLocale") | |
UserDefaults.standard.removeObject(forKey: "AppleLanguages") | |
UserDefaults.standard.synchronize() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment