Search code examples
iosiphonexcodeios7xctest

How to use helper methods of one XCTestCase subclass in another XCTestCase subclass?


I have two XCTestCase subclasses,

  1. @interface SessionTest : XCTestCase
  2. @interface UserTest : XCTestCase

In SessionTest class I am having helper method -(BOOL)Login;

I want to use this method in UserTest class, can someone tell me how to achieve this functionality.

Thanks.


Solution

  • You can create the third class:

    @interface TestHelper : NSObject
    

    implement -(BOOL)Login as method of TestHelper and use it from SessionTest and UserTest.

    As possible solution you can inherit UserTest from SessionTest:

    @interface UserTest : SessionTest