Luke Solomon
Luke Solomon

Reputation: 144

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

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?

Upvotes: 5

Views: 458

Answers (2)

Bill Chan
Bill Chan

Reputation: 3475

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)
        }
    }

Upvotes: 2

nomad00
nomad00

Reputation: 401

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;

Upvotes: 3

Related Questions