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,12 +6,13 @@
//
import Foundation
import XCTest
import Testing
@testable import ResgenSwift
class ImageFileParserTests: XCTestCase {
func testParseImagesFile() {
struct ImageFileParserTests {
@Test
func parseImagesFile() throws {
// Given
let input = """
#
@@ -29,24 +30,24 @@ class ImageFileParserTests: XCTestCase {
platform: PlatormTag.ios)
// Expect
XCTAssertEqual(parsedImages.count, 2)
#expect(parsedImages.count == 2)
let firstImage = parsedImages.first {
let firstImage = try #require(parsedImages.first {
$0.name == "image_one"
}
XCTAssertEqual(firstImage!.name, "image_one")
XCTAssertEqual(firstImage!.tags, "id")
XCTAssertEqual(firstImage!.width, 25)
XCTAssertEqual(firstImage!.height, -1)
XCTAssertEqual(firstImage!.imageExtensions, [.png])
})
#expect(firstImage.name == "image_one")
#expect(firstImage.tags == "id")
#expect(firstImage.width == 25)
#expect(firstImage.height == -1)
#expect(firstImage.imageExtensions == [.png])
let secondImage = parsedImages.first {
let secondImage = try #require(parsedImages.first {
$0.name == "image_two"
}
XCTAssertEqual(secondImage!.name, "image_two")
XCTAssertEqual(secondImage!.tags, "di")
XCTAssertEqual(secondImage!.width, -1)
XCTAssertEqual(secondImage!.height, 50)
XCTAssertEqual(firstImage!.imageExtensions, [.png])
})
#expect(secondImage.name == "image_two")
#expect(secondImage.tags == "di")
#expect(secondImage.width == -1)
#expect(secondImage.height == 50)
#expect(firstImage.imageExtensions == [.png])
}
}