FireMock icon indicating copy to clipboard operation
FireMock copied to clipboard

ConfigMock.mocks only use the first mock, right?

Open vietstone-ng opened this issue 8 years ago • 3 comments

Hi, I see

ConfigMock. mocks: [FireMockProtocol]

is an array, but in FireURLProtocol only the first element in the array is used

configMock.mocks.first

vietstone-ng avatar Mar 02 '17 11:03 vietstone-ng

Hi,

You right, the first element is used. This is an array because it allows to switch to the other elements with the custom view provide by the framework : FireMock.presentMockRegisters(from: self, backTapped: nil) With this line, you can switch to other mocks added on registers function at runtime.

Magiic avatar Mar 02 '17 21:03 Magiic

Oh, I see. But I think FireURLProtocol should also check for all elements in the array to get the first appropriate mock in case no mock is selected from view :)

vietstone-ng avatar Mar 03 '17 02:03 vietstone-ng

By default the first mock registers in variadic parameter is selected. Because It's impossible to know which mock is appropriate, the first mock added is selected on the view and used at launch.

Magiic avatar Mar 03 '17 14:03 Magiic