In the following bit of code appSettings variable initializes for every test case. How to make it initialize once for the whole test class? Using singleton would be a problem if it is used for several test classes when you run them together at once, because it will be initialized once for all test classes
final class TestsmthTests: XCTestCase {
var appSettings = AppSettings()
override func setUpWithError() throws {
}
func testExample() throws {
}
func testMore() throws {
}
}
Make it a static variable of your
XCTestCaseclass.I'd be reluctant to do this though because, the tests are meant to be independent and so, if you modify
appSettingsin a test, you may start seeing issues.