You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I enable swift 6 for tests, I get errors when trying to register mocks:
extension Container {
var testClass: Factory<TestClass> { self { TestClass() } }
}
final class TestClass {
var value = ""
}
final class TestCase: XCTestCase {
private let testClass = TestClass()
override func setUp() {
super.setUp()
Container.shared.testClass.register { self.testClass }
}
func test_value() {
}
}
I know that I could simply initialise TestClass inside closure Container.shared.testClass.register { TestClass() }, but I have a lot of cases when I keep an instance of mock and modify some properties inside test methods.
Two solutions that I could apply to fix it are:
Make TestClass Sendable and assign the instance to let variable before register
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When I enable swift 6 for tests, I get errors when trying to register mocks:
I know that I could simply initialise TestClass inside closure
Container.shared.testClass.register { TestClass() }
, but I have a lot of cases when I keep an instance of mock and modify some properties inside test methods.Two solutions that I could apply to fix it are:
Do you have some recommendations which solution I should choose?
Beta Was this translation helpful? Give feedback.
All reactions