Reputation: 315
I did not find a way to unit test an internal swift class that is inside a framework. It only works if I set the class scope to public. Is there a way around it ?
Here is what I have now:
In the framework:
class InternalClass {}
In the tests:
import XCTest
@testable import MyFramework
class InternalClassTests: XCTestCase {
let sut = InternalClass() //ERROR HERE Use of unresolved identifier 'InternalClass'
}
Upvotes: 4
Views: 1560
Reputation: 8546
You can use the @testable
before your framework import in your unit test file like
@testable import MyFramework
which give you access to at least your internal
method and classes in your framework.
Upvotes: 2
Reputation: 3007
If you want to use your InternalClass
as internal class, you must add your InternalClass
to your UnitTest
target.
You can simple do it by click to the checkbox of the Unit Test target, in the file's Target Membership
. (select your file and find it in the Inspectors
bar)
Upvotes: 1