Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run a KIF test that puts my app in the background?

Tags:

ios

cocoa

kif

I'm working on developing tests using KIF for a project. I want to know if it's possible to have KIF simulate a tap on the home button? Is it also possible to simulate other actions at that point, such as bringing up the command center or the notification center?

like image 787
Luke Solomon Avatar asked May 13 '15 20:05

Luke Solomon


2 Answers

At least a partial answer for you, take a look at deactivateAppForDuration in KIFTestActor.h:

/*!
 @abstract Backgrounds app using UIAutomation command, simulating pressing the Home button
 @param duration Amount of time for a background event before the app becomes active again
 */
- (void)deactivateAppForDuration:(NSTimeInterval)duration;
like image 54
nomad00 Avatar answered Nov 05 '22 05:11

nomad00


For swift 3 and Xcode 8, this function of KIFSystemTestActor works:

    system().deactivateApp(forDuration: 3)


    extension XCTestCase {    
            func system(_ file : String = #file, _ line : Int = #line) -> KIFSystemTestActor {
            return KIFSystemTestActor(inFile: file, atLine: line, delegate: self)
        }
    }
like image 2
Bill Chan Avatar answered Nov 05 '22 07:11

Bill Chan