【问题标题】:Can I run a KIF test that puts my app in the background?我可以运行将我的应用程序置于后台的 KIF 测试吗?
【发布时间】:2015-07-25 07:43:40
【问题描述】:

我正在为一个项目使用 KIF 开发测试。我想知道是否可以让 KIF 模拟点击主页按钮?是否也可以在此时模拟其他动作,例如调出指挥中心或通知中心?

【问题讨论】:

    标签: ios cocoa kif


    【解决方案1】:

    对于 swift 3 和 Xcode 8,KIFSystemTestActor 的这个功能有效:

        system().deactivateApp(forDuration: 3)
    
    
        extension XCTestCase {    
                func system(_ file : String = #file, _ line : Int = #line) -> KIFSystemTestActor {
                return KIFSystemTestActor(inFile: file, atLine: line, delegate: self)
            }
        }
    

    【讨论】:

      【解决方案2】:

      至少给你部分答案,看看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;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-15
        • 1970-01-01
        • 2019-04-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-02-10
        • 2019-09-23
        相关资源
        最近更新 更多