How to test launching a viewcontroller XCTest
Asked Answered
T

1

0

I have a framework under test, I want to test a method from public interface which user will call to show a ViewController with xib, I want to unit test this situation using XCTest, call to the method which does above described thing looks like this

testClass = [[AdGateMedia alloc] initWith:@"nac" and:@"1234" withParent:view];
[testClass showView];

The parent view controller is instance of calling view controller from host application which is using framework.

When testing this parent argument needs to be such that it will allow presenting of new controller possible.

There are two things 1. Is above type of testing possible ? 2. If yes how to do it using XCTest under iOS ?

Thanks

Tenaille answered 18/7, 2015 at 13:35 Comment(0)
P
3

Using XCode 7, you can easily do UI tests:

File -> new -> target -> iOS -> Test iOS UI Testing bundle

The generated code has some hints how to use it. Basically you place the cursor in your test method and then hit the red record button.

So you can simulate (almost) any user action. The generated code is more readable, when you name the UI elements for accessibility.

In your case, you use your method in a working (example) application.

(it has been possible before XCode 7 but with XCode 7 it's really easy to do)

Privy answered 19/7, 2015 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.