Imran Shams Imran Shams - 3 months ago 15
Swift Question

Xcode Test not detect my class

I have class named Meal.swift in my project and a unit test

func testMealInitialization() {
// Success case.
let potentialItem = Meal(name: "Newest meal", photo: nil, rating: 5)
XCTAssertNotNil(potentialItem)

// Failure cases.
let noName = Meal(name: "", photo: nil, rating: 0)
XCTAssertNil(noName, "Empty name is invalid")

}


But the problem is that: Use of unresolved identifier "Meal"

Answer

@testable import MyApp should work fine. Just remember to set appropriate configurations within Debug for your UITest target.

enter image description here