Migrate tests from XCTest to Swift Testing
openium/resgen.swift/pipeline/head There was a failure building this commit
openium/resgen.swift/pipeline/pr-master There was a failure building this commit

- Convert XCTestCase classes to structs with @Test functions
- Replace XCTAssert* with #expect, and force unwraps/XCTFail with #require
- Resolve test bundle via a class token in the CLI smoke test (Swift Testing
  does not register the .xctest bundle in Bundle.allBundles)
- Rename adaptForXCTest() to adaptForTest()
This commit is contained in:
t.schmitt committed 2026-11-23 15:53:21 +01:00
1 parent fdd23f4378
commit ac5d9cef58
24 files changed
+437 -374

No files matched your search

@@ -6,15 +6,16 @@
//
import Foundation
import XCTest
import Testing
@testable import ResgenSwift
final class AnalyticsSectionTests: XCTestCase {
struct AnalyticsSectionTests {
// MARK: - Matching tags
func testMatchingAnalytics() {
@Test
func matchingAnalytics() {
// Given
let section = AnalyticsCategory(id: "section_name")
section.definitions = [
@@ -37,13 +38,14 @@ final class AnalyticsSectionTests: XCTestCase {
let match4 = section.hasOneOrMoreMatchingTags(tags: ["droidonly"])
// Expect
XCTAssertTrue(match1)
XCTAssertTrue(match2)
XCTAssertTrue(match3)
XCTAssertTrue(match4)
#expect(match1)
#expect(match2)
#expect(match3)
#expect(match4)
}
func testNotMatchingAnalytics() {
@Test
func notMatchingAnalytics() {
// Given
let section = AnalyticsCategory(id: "section_name")
section.definitions = [
@@ -65,8 +67,8 @@ final class AnalyticsSectionTests: XCTestCase {
let match3 = section.hasOneOrMoreMatchingTags(tags: ["azerty"])
// Expect
XCTAssertFalse(match1)
XCTAssertFalse(match2)
XCTAssertFalse(match3)
#expect(match1 == false)
#expect(match2 == false)
#expect(match3 == false)
}
}