Closed adamsousa closed 6 months ago
This is why many people do unit tests on modules to test edge cases and then basically use UI testing for happy path smoke testing. Factory provides a certain level of support for such things, but if you're going to focus on UI tests for such things you're probably going to need to focus on using WireMock or some other external data source.
@hmlongco Makes sense, thanks for the response š
Hi, recently have started using Factory and I have a question revolving around UITesting and mocking dependancies. I've read through the testing documentation and looked through issues submitted here, but none have really answered my question.
My question pertains to mocking factory dependencies but with many variants of that dependancy. For example in my UI tests, I mock a network request response, but each test case tests a different enum value:
My understand is in order to mock this using Factory, I would have to create a
Container
extension that conforms toAutoRegistering
. From there I could do something like this:While this would work, this extension is already starting to become bloated with different responses. This won't scale well, as this extension will slowly become somewhat of a "monster class" as I add more tests and different mocked responses.
Ideally I would like these mock responses to be defined in my UITesting .swift files, that way their self contained. But I'm not able to do something like
private extension Container: AutoRegistering
as AutoRegistering is public. I've also found that a UI Testing Bundle does not have access to a Container created on the main application side, so my understand is thelaunchArguments
are my only way to interface with it.So I guess my real question is, is there a better way mock these objects? One that scales well? Maybe I'm just missing something here, appreciate your time!