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

@@ -8,12 +8,12 @@
// CPD-OFF
import Foundation
import XCTest
import Testing
import ToolCore
@testable import ResgenSwift
final class AnalyticsGeneratorTests: XCTestCase {
struct AnalyticsGeneratorTests {
private func getAnalyticsDefinition(
id: String,
@@ -208,7 +208,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
"""
}
func testGeneratedExtensionContentFirebase() {
@Test
func generatedExtensionContentFirebase() {
// Given
let sectionOne = AnalyticsCategory(id: "section_one")
sectionOne.definitions = [
@@ -420,10 +421,11 @@ final class AnalyticsGeneratorTests: XCTestCase {
if extensionContent != expect {
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
}
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
}
func testGeneratedExtensionContentMatomo() {
@Test
func generatedExtensionContentMatomo() {
// Given
let sectionOne = AnalyticsCategory(id: "section_one")
sectionOne.definitions = [
@@ -637,10 +639,11 @@ final class AnalyticsGeneratorTests: XCTestCase {
if extensionContent != expect {
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
}
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
}
func testGeneratedExtensionContentMatomoAndFirebase() {
@Test
func generatedExtensionContentMatomoAndFirebase() {
// Given
let sectionOne = AnalyticsCategory(id: "section_one")
sectionOne.definitions = [
@@ -860,7 +863,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
if extensionContent != expect {
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
}
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
#expect(extensionContent.adaptForTest() == expect.adaptForTest())
}
}