KIF + Swift重置/重启应用

时间:2017-03-13 15:36:18

标签: swift automated-tests kif

我正在使用KIF和Swift开发自动化测试 我写了一些测试,但他们并不相互依赖 如何重置app并在beforeEach()方法中执行它?

class PassengerCountTests: KIFTestCase {

enum Element: String {
    case passengerCount = "passengerCount_label"
    case plusButton = "plus_button"
    case minusButton = "minus_button"

}

func getElement(element: Element) -> UIView {
    return tester().waitForView(withAccessibilityLabel: element.rawValue)
}

func tap(element: Element) {
    tester().tapView(withAccessibilityLabel: element.rawValue)
}


func testMinPassengerNumber() {
    let passengerCount = getElement(element: Element.passengerCount)
    let minusButton = getElement(element: Element.minusButton)

    XCTAssertEqual(passengerCount.accessibilityValue, "1")
    XCTAssertEqual(minusButton.isProbablyTappable, false)
}

func testMaxPassengerNumber() {
    for _ in 1...4 {
        tap(element: Element.plusButton)
    }

    let passengerCount = getElement(element: Element.passengerCount)
    let plusButton = getElement(element: Element.plusButton)

    XCTAssertEqual(passengerCount.accessibilityValue, "5")
    XCTAssertEqual(plusButton.isProbablyTappable, false)
}

}

0 个答案:

没有答案