admin管理员组

文章数量:1125782

I have several tests written for a series of static properties within an extension in Swift, but I can't get SonarQube to mark them as covered.

I've tried everything, but even with the following code, it still says they are not covered. Any ideas?

import XCTest
import SwiftUI
@testable import Core

class FontTests: XCTestCase {
    
    func testFontProperties() {
        
        XCTAssertNotNil(Font.flamaBook)
        XCTAssertNotNil(Font.flamaBasic)
        XCTAssertNotNil(Font.flamaMedium)
        
    }
    
    func testCustomFontDefinitions() {
        
        XCTAssertEqual(Font.flamaBook, "Flama-Book")
        XCTAssertEqual(Font.flamaBasic, "Flama-Basic")
        XCTAssertEqual(Font.flamaMedium, "Flama-Medium")
        
    }
    
    func testFontStyles() {
        
        XCTAssertEqual(Font.h1, Font.custom(Font.flamaBook, size: 24))
        XCTAssertEqual(Font.h2, Font.custom(Font.flamaBook, size: 18))
        XCTAssertEqual(Font.h3, Font.custom(Font.flamaBook, size: 16))
        XCTAssertEqual(Font.h4, Font.custom(Font.flamaMedium, size: 14))
        XCTAssertEqual(Font.p1, Font.custom(Font.flamaBook, size: 15))
        XCTAssertEqual(Font.p2, Font.custom(Font.flamaMedium, size: 12))
        XCTAssertEqual(Font.p3, Font.custom(Font.flamaBasic, size: 12))
        XCTAssertEqual(Font.link, Font.custom(Font.flamaBook, size: 16))
        XCTAssertEqual(Font.formElement, Font.custom(Font.flamaBook, size: 15))
        XCTAssertEqual(Font.formElementBasic, Font.custom(Font.flamaBasic, size: 15))
        XCTAssertEqual(Font.button, Font.custom(Font.flamaBook, size: 16))
        XCTAssertEqual(Font.otp, Font.custom(Font.flamaBasic, size: 30))
        XCTAssertEqual(Font.balance1, Font.custom(Font.flamaBasic, size: 22))
        XCTAssertEqual(Font.balance2, Font.custom(Font.flamaBasic, size: 36))
        XCTAssertEqual(Font.tabBar, Font.custom(Font.flamaMedium, size: 11))
        
    }
    
}

本文标签: testingSwift static properties are not marked as covered by tests in SonarQubeStack Overflow