-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also adds support for customising the separator used when generating the test name.
- Loading branch information
1 parent
7a24179
commit 3110804
Showing
32 changed files
with
2,619 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ParameterizedTestCase.swift | ||
// Copyright © 2023 Cameron Cooke. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import XCTest | ||
|
||
open class ParameterizedTestCase: XCTestCase { | ||
|
||
// MARK: - Open - | ||
|
||
open class var testNameFieldSeparator: String { | ||
"_" | ||
} | ||
|
||
// MARK: - Internal - | ||
|
||
private var storage: [String: Any] = [:] | ||
|
||
func setValue<T>(_ value: T, forKey key: String) { | ||
storage[key] = value | ||
} | ||
|
||
func getValue<T>(forKey key: String) -> T? { | ||
return storage[key] as? T | ||
} | ||
|
||
static func testName(for values: [Any]) -> String { | ||
values | ||
.map { String(describing: $0) } | ||
.joined(separator: testNameFieldSeparator) | ||
.lowercased() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.