Files
resgen.swift/Tests/ResgenSwiftTests/Generate/AnalyticsConfigurationTests.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

83 lines
2.1 KiB
Swift

//
// AnalyticsConfigurationTests.swift
// ResgenSwift
//
// Created by Thibaut Schmitt on 18/07/2025.
//
import Foundation
@testable import ResgenSwift
import Testing
struct AnalyticsConfigurationTests {
let projectDirectory = "projectDirectory/"
@Test
func argsGeneration_requiredArgs() {
// Given
let testingConfiguration = AnalyticsConfiguration(
inputFile: "path/to/tags.yml",
target: "matomo firebase",
outputFile: "Analytics/Generated/AnalyticsManager.swift",
visibility: nil,
staticMembers: nil,
pathSuffix: nil
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: false
)
// Expect
let expectedArguments = [
"projectDirectory/path/to/tags.yml",
"--target",
"matomo firebase",
"--output-file",
"projectDirectory/Analytics/Generated/AnalyticsManager.swift",
]
#expect(arguments == expectedArguments)
}
@Test
func argsGeneration_allArguments() {
// Given
let testingConfiguration = AnalyticsConfiguration(
inputFile: "path/to/tags.yml",
target: "matomo firebase",
outputFile: "Analytics/Generated/AnalyticsManager.swift",
visibility: "public",
staticMembers: false,
pathSuffix: "mySuffix"
)
// When
let arguments = testingConfiguration.getArguments(
projectDirectory: projectDirectory,
force: true
)
// Expect
let expectedArguments = [
"-f",
"projectDirectory/path/to/tags.yml",
"--target",
"matomo firebase",
"--output-file",
"projectDirectory/Analytics/Generated/AnalyticsManager.swift",
"--visibility",
"public",
"--static-members",
"false",
"--path-suffix",
"mySuffix"
]
#expect(arguments == expectedArguments)
}
}