mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-10 22:45:59 +05:45
* Create a swift utility for collecting code coverage and uploading to a database * Update the readme * Code clean up * Fix line length * Change to a still supported commandline kit * Run swift formatter * Add copyright * Move example report under the Tests dir * Add a TODO for Firestore, Functions, and InAppMessaging * Change todo name to GitHub name * Put line breaks in the example report
40 lines
1.3 KiB
Swift
40 lines
1.3 KiB
Swift
/*
|
|
* Copyright 2019 Google
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import MetricsLib
|
|
import XCTest
|
|
|
|
let EXAMPLE_REPORT = "Tests/MetricsTests/example_report.json"
|
|
|
|
final class CoverageReportTests: XCTestCase {
|
|
func testShouldParseTotalCoverage() throws {
|
|
let report = try CoverageReport.load(path: EXAMPLE_REPORT)
|
|
XCTAssertEqual(report.coverage, 0.5490569575543673)
|
|
}
|
|
|
|
func testShouldParseTargets() throws {
|
|
let report = try CoverageReport.load(path: EXAMPLE_REPORT)
|
|
XCTAssertEqual(report.targets.count, 14)
|
|
XCTAssertEqual(report.targets[0].name, "Auth_Example_iOS.app")
|
|
XCTAssertEqual(report.targets[0].coverage, 0.8241201927002532)
|
|
XCTAssertEqual(report.targets[0].files.count, 97)
|
|
}
|
|
|
|
func testShouldFailOnMissingFile() throws {
|
|
XCTAssertThrowsError(try CoverageReport.load(path: "IDontExist"))
|
|
}
|
|
}
|