Another way is to let the class customize the behavior controlled by the static method and have a test call that calls this method in its static load method.
I had a similar problem using storyboards and an external sedative service for authentication through oauth. The application delegate will check if appdelegate has a valid oauth token: didFinishLaunchingWithOptions, and if not, programmatically run segue to log in to oauth. But this was undesirable in test cases. To solve this problem, I created a static method in the application delegate to disable the login screen. This is the code inside my application delegate:
static Boolean showLoginScreen = TRUE ; + (void) disableLoginScreen { showLoginScreen = FALSE ; NSLog(@"disabled login screen") ; }
In the test example, the boot method was set:
// disable login screen for the test case + (void) load { NSLog( @"now disabling login screen" ) ; [XYZAppDelegate disableLoginScreen]; }
This worked because the test case class was loaded before the application was initialized. Of course, you should check the value of this flag in the application delegate in order to start / not start the login. Other alternatives that I tried but rejected were as follows:
source share