- I am writing test cases in objective C in Xcode and for that test case to execute I require class function of some other class to execute and give result. But the problem that I am getting is the value from the class function is always nil.Due to which my test case always fails. Can anyone please share a link or explain how to use test case in this scenario.
Can we call a class function within Test cases written in XCode
Are these unit tests or UI tests?
Unit tests absolutely can access class functions from the unit test's root code base, which is likely your main app. If this is failing you, we'd need to know more about your situation, because this is just what a unit test is allowed to do by default. There's not really any trick to it.
UI tests are like an entirely separate app (the UI Test Runner) which is simply controlling your main app, in a "black box" way.
As such, UI tests cannot access the internal code or state of the main app, they can only observe the results of actions as expressed in the accessibility layer. They cannot run code arbitrary code contained within the main app, however you could theoretically create a "testing mode" for your main app which would accept input, run specific functions, and report back the result. In other words, you could create a UI that is only for testing purposes which lets you tell the app to run code for you, but you cannot run it yourself. Does that make sense?
Thanks for the reply.
And I am writing Unit test cases