iosxcodetestingautomated-testsearlgrey

EarlGrey launches APP with black screen


After successfully adding EarlGrey to existing project (using CocoaPods) project is successfully built (both "for running" and "for testing"). The problem is that if I run the app from XCode it runs as expected. If I run it as a test only splash screen appears and then whole screen turns black. Have anyone encountered such issue? What might be a problem here?

There is somewhat similar question Black screen with EarlGrey but author did not share his solution.

Additional info:


Solution

  • I followed @khandpur advice and tried debugging my app first. So I found out, that in main.m file we're checking if current run is a test run, by

    BOOL areWeRunningTests = NSClassFromString(@"XCTestCase") != nil;

    Based on that we are running app differently.

    To everyone in similar situation: I've added a check

    BOOL areWeRunningUITests = NSClassFromString(@"EarlGreyImpl") != nil;

    and if that's true app is starting normally.

    Final comments - you have to know your app a little to be able to use EarlGrey easily... :)