3

I have code similar to the below snippet

class MainViewController: UIViewController {

      private var bLogin = true
}

From XCTest file, how can I access "bLogin" variable?

Thanks

1 Answer 1

1

If you are using Swift 2.0 add @testable to the import statement:

@testable import MyMainModule
Sign up to request clarification or add additional context in comments.

2 Comments

I am using Swift 1.2 :(
In that case you have to add the source file to the test project and change access modifier from private to internal. There isn't a good way to test private methods in Swift 1.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.