Files
resgen.swift/Tests/ResgenSwiftTests/Generate/StringsConfigurationTests.swift
T
t.schmitt ac5d9cef58
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
Migrate tests from XCTest to Swift Testing
- 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()
2026-11-23 15:53:21 +01:00

105 lines
2.8 KiB
Swift

//
// StringsConfigurationTests.swift
// ResgenSwift
//
// Created by Thibaut Schmitt on 18/07/2025.
//
import Foundation
@testable import ResgenSwift
import Testing
struct StringsConfigurationTests {
let projectDirectory = "projectDirectory/"
@Test
func argsGeneration_requiredArgs() {
// Given
let testingConfiguration = StringsConfiguration(
inputFile: "path/to/strings.txt",
outputPath: "Strings/Generated",
langs: "fr en en-us",
defaultLang: "en",
extensionOutputPath: nil, // Strings/Generated
extensionName: nil, // String
extensionSuffix: nil, // Testing
visibility: nil, // "internal"
assetBundle: nil, // .main
staticMembers: nil, // true
xcStrings: nil // true
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect
let expectedArguments = [
"projectDirectory/path/to/strings.txt",
"--output-path",
"projectDirectory/Strings/Generated",
"--langs",
"fr en en-us",
"--default-lang",
"en"
]
#expect(arguments == expectedArguments)
}
@Test
func argsGeneration_allArguments() {
// Given
let testingConfiguration = StringsConfiguration(
inputFile: "path/to/strings.txt",
outputPath: "Strings/Generated",
langs: "fr en en-us",
defaultLang: "en",
extensionOutputPath: "Strings/Generated",
extensionName: "AppString",
extensionSuffix: "Testing",
visibility: "internal",
assetBundle: "module",
staticMembers: true,
xcStrings: true
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect
let expectedArguments = [
"-f",
"projectDirectory/path/to/strings.txt",
"--output-path",
"projectDirectory/Strings/Generated",
"--langs",
"fr en en-us",
"--default-lang",
"en",
"--extension-output-path",
"projectDirectory/Strings/Generated",
"--extension-name",
"AppString",
"--extension-suffix",
"Testing",
"--visibility",
"internal",
"--asset-bundle",
"module",
"--xc-strings",
"true",
"--static-members",
"true"
]
#expect(arguments == expectedArguments)
}
}