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
It looks to be similar to: #50 which was marked as fixed.
I have a SessionManager initialized as a singleton and then used in the service under test. I first stub everything with Mockingjay and then call one of the service's methods, this in turn makes a request using Alamofire SessionManager. And the real request goes through.
Now, if I don't use the singleton SessionManager and create it inside the test, then pass it to the service under test, then Mockingjay stubbing works.
Interestingly enough, in the original scenario, the SessionManager singleton is actually only called (so, initialized) for the first time in the service under test (I don't use the real AppDelegate in unit tests), meaning (I might still be wrong on this though) that the stub is called before the SessionManager is even created and still this fails to work...
Xcode 9.3
Swift 4.1
Alamofire 4.7.2
Mockingjay 2.0.1
EDIT
OK, this is more clear now. It's not about just SessionManager, but about the manager using non-default configuration:
static let sessionManager: Alamofire.SessionManager = {
let configuration = URLSessionConfiguration.background(withIdentifier: "XXX")
configuration.timeoutIntervalForRequest = 60
return Alamofire.SessionManager(configuration: configuration)
}()
When not using background configuration, stubbing works.
The text was updated successfully, but these errors were encountered:
NeverwinterMoon
changed the title
Not working with Alamofire SessionManager singleton
Not working with URLSessionConfiguration.background
Apr 24, 2018
It looks to be similar to: #50 which was marked as fixed.
I have a SessionManager initialized as a singleton and then used in the service under test. I first stub everything with Mockingjay and then call one of the service's methods, this in turn makes a request using Alamofire SessionManager. And the real request goes through.
Now, if I don't use the singleton SessionManager and create it inside the test, then pass it to the service under test, then Mockingjay stubbing works.
Interestingly enough, in the original scenario, the SessionManager singleton is actually only called (so, initialized) for the first time in the service under test (I don't use the real AppDelegate in unit tests), meaning (I might still be wrong on this though) that the stub is called before the SessionManager is even created and still this fails to work...
Xcode 9.3
Swift 4.1
Alamofire 4.7.2
Mockingjay 2.0.1
EDIT
OK, this is more clear now. It's not about just SessionManager, but about the manager using non-default configuration:
When not using background configuration, stubbing works.
The text was updated successfully, but these errors were encountered: