lundi 13 juillet 2020

Why can't my unit test access a public static constant in my model?

My project structure is shown below:

enter image description here

Class Exposure:

class Exposure: ObservableObject {
    @Published var selected = [Int](repeating: 0, count: 3)
    
    private static let File = readFile()
    public static let Triangle = K.SettingIncrementKeys
        .map { readValues(json: File, key: $0) }
   ...
}

Class XCTestCase:

import XCTest
@testable import Exposed

class Exposure: XCTestCase {
    public func testJSONLoading() throws {
        let triangle = Exposure.Triangle
        XCTAssertEqual(triangle.count, 3)
    }
}

I'm getting a compilation error "Type 'Exposure' has no member 'Triangle'". How do I make the test see the static field?

Aucun commentaire:

Enregistrer un commentaire