我正在使用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)
}
}