Reputation: 3926
Before asking the question, I should say this. My understanding about UI Testing in Xcode:
My scenario:
I want to call a method (Say myMethod()
) in the view controller (Say MyVC.h/MyVC.m
) in my source code from my UI Test case.
Note: My source code was written in Objective C, and I am writing test cases in Swift.
From my understanding, to do this, I should add MyVC.m
(We can not add .h to the target) in UITest target also. Then I need to import MyVC.h
in my UITest bridging file. Then I can call myMethod()
from UITest like this:
MyVC.myMethod()
It will work!!
The problem:
In real time, most of the classes use Util classes, Constant files(Header files), classes that was imported from .pch file, Shared managers, etc.
If MyVC
is a independent class, means which will not use any of the classes said above, I can access myMethod()
without any problem.
But, if MyVC
uses those classes indirectly, running UITest shows missing header files errors in all source code.
What I tried:
Question:
Should I add all needed files header in all files of main source?
Have anyone faced this type of error? Did anyone done DB access from UI Testing?
Upvotes: 1
Views: 1692
Reputation: 36143
Two things:
I think the second bit might not matter for your needs, since from the bit about hitting a database from the UI test makes it sound like you don't need the specific object in the app, just an object of that class to get at some DB access methods that are declared on it for some reason. For that, just being able to compile in the class and instantiate and message it suffices. (You might still make your life easier by factoring those DB-related methods out to a non-UI class, though.)
Upvotes: 1