Skip to content

Commit

Permalink
Fixed mixed tests parsing (#29)
Browse files Browse the repository at this point in the history
* Fixed mixed tests parsing

* Added test for mixed tests

Tests
  • Loading branch information
AllDmeat authored Feb 28, 2024
1 parent ebdeee5 commit 3fda06d
Show file tree
Hide file tree
Showing 124 changed files with 38 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ extension DBXCReportModel {
repeatableTests: [])
try value5.subtests?._values.forEach { value6 in
let testname = value6.name._value
let test = try DBXCReportModel.Module.File.RepeatableTest.Test(value6, xcresultPath: xcresultPath)
let repeatableTest = file.repeatableTests[testname] ?? DBXCReportModel.Module.File.RepeatableTest(
var repeatableTest = file.repeatableTests[testname] ?? DBXCReportModel.Module.File.RepeatableTest(
name: testname,
tests: [test]
tests: []
)
let test = try DBXCReportModel.Module.File.RepeatableTest.Test(value6, xcresultPath: xcresultPath)
repeatableTest.tests.append(test)
file.repeatableTests.update(with: repeatableTest)
}
module.files.update(with: file)
Expand Down
6 changes: 3 additions & 3 deletions Tests/DBXCResultParserTests/CoverageDTOTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CoverageDTOTests: XCTestCase {
let result = try Array<CoverageDTO>(from: Constants.testsReportPath)
XCTAssertEqual(result.count, 5) // as targets count
let expectedResult = CoverageDTO.testMake(
coveredLines: 477,
executableLines: 532,
lineCoverage: 0.8966165413533834,
coveredLines: 481,
executableLines: 535,
lineCoverage: 0.8990654205607477,
name: "DBXCResultParser"
)

Expand Down
35 changes: 28 additions & 7 deletions Tests/DBXCResultParserTests/DBXCReportModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,37 @@ class DBXCReportModelTests: XCTestCase {
XCTAssertEqual(report.modules.count, 2)

let module = try XCTUnwrap(report.modules.first { $0.name == "DBXCResultParserTests" })
XCTAssertEqual(module.coverage?.coveredLines, 477)
XCTAssertEqual(module.coverage?.coveredLines, 481)

let files = module.files.sorted { $0.name < $1.name }
XCTAssertEqual(files.count, 5)

let file = try XCTUnwrap(files.first { $0.name == "DBXCReportModelTests" })
XCTAssertEqual(file.repeatableTests.count, 4)
XCTAssertEqual(file.repeatableTests.count, 6)

let successTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test()" })
let failedTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_failure()" })
let skippedTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_skip()" })
let expectedFailedTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_expectedFailure()" })
let successTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_success()" })
XCTAssertNil(successTest.tests.first?.message)

let failedTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_failure()" })
XCTAssertEqual(failedTest.tests.first?.message, "failed - Failure message")

let skippedTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_skip()" })
XCTAssertEqual(skippedTest.tests.first?.message, "Test skipped - Skip message")

let expectedFailedTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_expectedFailure()" })
XCTAssertEqual(expectedFailedTest.tests.first?.message, "XCTAssertEqual failed: (\"1\") is not equal to (\"2\")")
XCTAssertNil(successTest.tests.first?.message)

let flackyTest = try XCTUnwrap(file.repeatableTests.first { $0.name == "test_flacky()" })
XCTAssertEqual(flackyTest.tests.count, 2)
XCTAssertEqual(flackyTest.tests.first?.status, .failure)
XCTAssertEqual(flackyTest.tests.last?.status, .success)
XCTAssertEqual(flackyTest.combinedStatus, .mixed)
}

// func test_success() {
// XCTAssertTrue(true)
// }
//
// func test_failure() {
// XCTFail("Failure message")
// }
Expand All @@ -50,4 +62,13 @@ class DBXCReportModelTests: XCTestCase {
// XCTExpectFailure("Failure is expected")
// XCTAssertEqual(1, 2)
// }
//
// static var shouldFail = true
// func test_flacky() {
// if Self.shouldFail {
// XCTFail("Flacky failure message")
// }
//
// Self.shouldFail = false
// }
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":2,"name":"DBXCResultParserTests-7883ABBD-8541-4079-83F9-09B66E6EC7C7"},{"name":"scheduling.log","type":1}]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<plist version="1.0">
<dict>
<key>dateCreated</key>
<date>2024-02-27T07:03:24Z</date>
<date>2024-02-28T11:22:54Z</date>
<key>externalLocations</key>
<array/>
<key>rootId</key>
<dict>
<key>hash</key>
<string>0~N01d67zanadjN089Qsor6PcBJUU7hYqMnVq2jdocGEg-iHypK88o3upIelnwxs_Yn1DbG0_gXDRJKMHqC2avAg==</string>
<string>0~A_E6tkLvKUCOj_ilhAxfKD_wFRUVttAri6Za6Q_5DxFNl7ZgQTVcsZoa6kR4UwShTLdcvJNlQpSxlhZjjTLRAg==</string>
</dict>
<key>storage</key>
<dict>
Expand Down
Binary file not shown.

0 comments on commit 3fda06d

Please sign in to comment.