0

To write a UI Testcase for the first screen seems to be very simple.

As shown below.

func testExample() {

        let app = XCUIApplication()
        let textField = app.otherElements.containing(.navigationBar, identifier:"id").children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .textField).element
        textField.tap()
        textField.tap()
        app.navigationBars["id"].buttons["Done"].tap()

    }

But how to write a test case , where one navigation controller triggers another screen as shown a below.

Navigation Controller -> UIViewController1 -> UIViewcontroller2 .....UIViewController5

To test the UIViewController5, I will have to write massive lines of code which will include the following logic

1) Launch the App.

2) Launch Controller1 ,perform the event to Launch Controller2

3) Repeat the step 2, till it reaches Controller5.

I belive the UI test case should be simple and should not take time.

What should be ideal approach in this case, as to run the test case for Controller5, it will have to execute all events before it?

NNikN
  • 3,720
  • 6
  • 44
  • 86
  • You will need to accept some compromise on speed to take full advantage of XCTest's UI testing abilities. That is the cost of testing at the UI level. For faster tests, use unit/component/other integration tests. UI tests are slow, but they are also more authentic and closer to the end user's experience - that's where their value is, not in their speed. – Oletha Apr 30 '18 at 14:24
  • Possible duplicate of [Is it possible to open a screen directly in XCUITest?](https://stackoverflow.com/questions/49020329/is-it-possible-to-open-a-screen-directly-in-xcuitest) – Mladen May 01 '18 at 19:09

0 Answers0