I am trying to test a class I have written. I have added a new test target and in there I have imported the target of the class I am trying to test. My code looks like this:
import XCTest
import TargetContainingClass
class Tests: XCTestCase
{
var myClass = MyClass()
// tests
}
However, I get the error:
'MyClass' is not constructible with '()'
MyClass
does not contain an init()
method so does not need to be constructed with anything. I therefore don't understand the error I am getting.
Any help here would be greatly appreciated.
Cheers
You need to provide an implementation of
init()
as:The Swift documentation states:
But the above is apparently not true; in action: