Laurence Wingo
Laurence Wingo

Reputation: 3952

Unit test error says argument does not match any available overloads

I'm practicing TDD and I'm running into a very simple error right off the bat but cannot figure out why. This is the first unit test case of the project and it won't compile when I'm thinking I have everything in place as expected.

The unit test case code reads:

import XCTest
@testable import PassionProject

class ToDoItem: XCTestCase {

    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }

    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }

    func test_Init_TakesTitle(){
        ToDoItem(title: "Instance Ones Title")

    }
}

And the model is in place by creating a ToDoItem class in the proper target, that code reads:

struct ToDoItem {

    let title: String

}

After searching stackoverflow other answers solve the this error by making sure the parameter name is listed for Swift 3 and other examples on stackoverflow were for functions that returned a type. In this example, I'm not returning a type and the parameter name is listed when creating the instance. Can someone point me in the direction to learn what I've done wrong and secondly what does Xcode mean when saying "any available overloads"? My online search turned up tutorials on function overloads but a struct isn't a function, right?

Thank you in advance for any explanations to understand what Xcode is saying precisely in this example.

Upvotes: 1

Views: 155

Answers (1)

Jon Reid
Jon Reid

Reputation: 20980

You use the same name ToDoItem for two separate things: the test suite, and the system under test.

Rename your test suite. For example: ToDoItemTests

Upvotes: 3

Related Questions