Migrate tests from XCTest to Swift Testing #26

Merged
t.schmitt merged 3 commits from feature/swift-testing-migration into master 2026-11-23 16:25:37 +01:00
Owner

Summary

Migrates the whole ResgenSwiftTests target from XCTest to Swift Testing. Same 92 tests, now in 23 suites, all passing with swift test.

Changes

  • XCTestCase classes → struct suites, func testXxx() → @Test func xxx()
  • XCTAssert* → #expect(...) (XCTAssertFalse(x) → #expect(x == false))
  • Force unwraps / as! / XCTFail guards → try #require(...):
    • ImageFileParserTests, SectionTests, DefinitionTests, ColorFileParserTests
    • ParsedColorTests.generatedColorAsset rewritten without as!
  • ResgenCLITests: Swift Testing does not register the .xctest bundle in Bundle.allBundles, so the products directory is now resolved via Bundle(for: BundleToken.self). Removed the obsolete #available(macOS 10.13) guard and the self-comparing XCTAssertEqual(output, output).
  • Renamed helper adaptForXCTest() → adaptForTest()

Note

Pre-existing issue left as-is: the last assertion of ImageFileParserTests.parseImagesFile checks firstImage.imageExtensions where secondImage was probably intended (its expected value would then be webp png, not [.png]).

Test plan

  • swift test → 92 tests in 23 suites passed
## Summary Migrates the whole `ResgenSwiftTests` target from XCTest to Swift Testing. Same 92 tests, now in 23 suites, all passing with `swift test`. ## Changes - `XCTestCase` classes → `struct` suites, `func testXxx()` → `@Test func xxx()` - `XCTAssert*` → `#expect(...)` (`XCTAssertFalse(x)` → `#expect(x == false)`) - Force unwraps / `as!` / `XCTFail` guards → `try #require(...)`: - `ImageFileParserTests`, `SectionTests`, `DefinitionTests`, `ColorFileParserTests` - `ParsedColorTests.generatedColorAsset` rewritten without `as!` - `ResgenCLITests`: Swift Testing does not register the `.xctest` bundle in `Bundle.allBundles`, so the products directory is now resolved via `Bundle(for: BundleToken.self)`. Removed the obsolete `#available(macOS 10.13)` guard and the self-comparing `XCTAssertEqual(output, output)`. - Renamed helper `adaptForXCTest()` → `adaptForTest()` ## Note Pre-existing issue left as-is: the last assertion of `ImageFileParserTests.parseImagesFile` checks `firstImage.imageExtensions` where `secondImage` was probably intended (its expected value would then be `webp png`, not `[.png]`). ## Test plan - [x] `swift test` → 92 tests in 23 suites passed
t.schmitt added 1 commit 2026-11-23 15:54:08 +01:00
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
ac5d9cef58
- 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()
Member

❌ Job openium/resgen.swift/PR-26 - Build #1
took 11 sec
▹ Stages => build-dependencies ❌

openium/resgen.swift/PR-26 - #1

❌ Job openium/resgen.swift/PR-26 - Build #1 _took 11 sec_ ▹ [Stages](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/1/display/redirect) => build-dependencies ❌ [openium/resgen.swift/PR-26 - #1](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/1/)
t.schmitt added 1 commit 2026-11-23 15:55:44 +01:00
Update Jenkins to Xcode 27.1.0
openium/resgen.swift/pipeline/pr-master This commit is unstable
dc6c479978
Member

ⅹ → ⚠️ Job openium/resgen.swift/PR-26 - Build #2
took 1 min 39 sec
▹ Stages => quality ⚠️
▹ Lines => 10669 (Swift: 8950, Markdown: 591, YAML: 365, ...)
▹ Coverage => 73.23% (6315/8624 lines)
▹ Tests       => Passed: 185, Failed: 0, Skipped: 0
▹ Screenshots => 0 images
▹ Quality => CPD Duplications: 0, CheckStyle Warnings: 2

openium/resgen.swift/PR-26 - #2

ⅹ → ⚠️ Job openium/resgen.swift/PR-26 - Build #2 _took 1 min 39 sec_ ▹ [Stages](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/2/display/redirect) => quality ⚠️ ▹ [Lines](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26//sloccountResult) => 10669 (Swift: 8950, Markdown: 591, YAML: 365, ...) ▹ [Coverage](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/2//coverage) => 73.23% (6315/8624 lines) ▹ [Tests](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/2/display/redirect?page=tests)       => Passed: 185, Failed: 0, Skipped: 0 ▹ [Screenshots](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/Screenshots) => 0 images ▹ Quality => [CPD Duplications](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/2/cpd): 0, [CheckStyle Warnings](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/2/checkstyle): 2 [openium/resgen.swift/PR-26 - #2](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/2/)
t.schmitt added 1 commit 2026-11-23 16:13:20 +01:00
Fix SwiftLint warnings: prefer_self_in_static_references and file_length
openium/resgen.swift/pipeline/pr-master This commit looks good
1eb2ea9e5d
Member

⚠ → ✅ Job openium/resgen.swift/PR-26 - Build #3
took 1 min 29 sec
▹ Stages => all ✔
▹ Lines => 10660 (Swift: 8950, Markdown: 591, YAML: 365, ...)
▹ Coverage => 73.23% (6315/8624 lines)
▹ Tests       => Passed: 185, Failed: 0, Skipped: 0
▹ Screenshots => 0 images
▹ Quality => CheckStyle Warnings: 0, CPD Duplications: 0

openium/resgen.swift/PR-26 - #3

⚠ → ✅ Job openium/resgen.swift/PR-26 - Build #3 _took 1 min 29 sec_ ▹ [Stages](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/3/display/redirect) => all ✔ ▹ [Lines](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26//sloccountResult) => 10660 (Swift: 8950, Markdown: 591, YAML: 365, ...) ▹ [Coverage](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/3//coverage) => 73.23% (6315/8624 lines) ▹ [Tests](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/3/display/redirect?page=tests)       => Passed: 185, Failed: 0, Skipped: 0 ▹ [Screenshots](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/Screenshots) => 0 images ▹ Quality => [CheckStyle Warnings](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/3/checkstyle): 0, [CPD Duplications](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/3/cpd): 0 [openium/resgen.swift/PR-26 - #3](https://jenkins.openium.fr/job/openium/job/resgen.swift/job/PR-26/3/)
t.schmitt merged commit 58b049c629 into master 2026-11-23 16:25:37 +01:00
t.schmitt deleted branch feature/swift-testing-migration 2026-11-23 16:25:37 +01:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openium/resgen.swift#26