Application State / Test Fixtures with Xcode UI Tests -


a pretty common problem kind of integration test getting unit under test known state -- state sets test want perform. unit test, there's not state, , issue in potentially mocking out interactions other classes.

on other hand, when testing whole app there's sorts of potentially persistent state, , getting app clean state, or trickier still, known state isn't "clean" without access app little tricky.

the suggestion i've found embed necessary setup in app, , use environment variable trigger setup. is, of course, viable, it's not ideal. don't want embed test code , test data in final application if can avoid it.

and there's mocking out interactions remote services. again can embed code (or framework) that, , trigger environment variable, again don't love idea of embedding stubbing code final app.

suggestions? haven't been able find much, makes me wonder if no-one using xcode ui testing, or using incredibly simple apps don't have these kinds of issues.

unfortunately, 2 suggestions mentioned ones possible xcode ui testing in current state.

there is, however, 1 thing can mitigate risk of embedding test code in production app. of few compiler flags can ensure specific code built when running on simulator.

#if (arch(i386) || arch(x86_64)) && os(ios)     class seededhttpclient: httpclientprotocol {         /// ... //     } #endif 

i'm in middle of building make little easier. i'll report when ready use.


Comments