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

Senseful
  • 86,719
  • 67
  • 308
  • 465
vishal dharankar
  • 7,536
  • 7
  • 57
  • 93

1 Answers1

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)

Gerd Castan
  • 6,275
  • 3
  • 44
  • 89