Application Status / Test Lights with Xcode Interface Checks

A fairly common problem with any type of integration test is testing the device under test in a known state - a state that is well suited for the test you want to run. With unit test, there is usually not much state, and the only problem is potential mockery interaction with other classes.

On the other hand, when testing the whole application, there are all kinds of potentially persistent state and getting the application in a clean state or even more difficult in a known state that is not “clean” without any access to the application itself is a bit more complicated.

The only thing I found was to include any necessary configuration in the application and use something like an environment variable to start the installation. It is, of course, viable, but it is not ideal. I really don't want to embed test code and test data in my final application, if I can avoid it.

And then they mock at interacting with remote services. Again, you can embed code (or even a framework) for this and run it using an environment variable, but again I don't like the idea of ​​embedding the stub code in the final application.

Suggestions? I have not been able to find much that makes me wonder if anyone is using Xcode UI testing or only using it for incredibly simple applications that do not have such problems.

+4
source share
2 answers

Unfortunately, the two suggestions you mentioned are the only ones that are possible when testing the Xcode UI in its current state.

However, there is one thing you can do to reduce the risk of introducing test code into your production application. With the help of several flags of the compiler, you can guarantee that specific code will be created only when run on the simulator.

#if (arch(i386) || arch(x86_64)) && os(iOS)
    class SeededHTTPClient: HTTPClientProtocol {
        /// ... //
    }
#endif

I am going to create something to make it a little easier. I will send a report when it is ready for use.

+2
source

. , simulator/Library/Caches. , , /Library/Caches setUp() , .

. .

, .

, , - ( ). Embassy .

+1

Source: https://habr.com/ru/post/1626486/


All Articles