Skip to content

Commit

Permalink
Add ability to override test names
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncooke committed Dec 5, 2022
1 parent 94a6009 commit c102bac
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 11 deletions.
6 changes: 5 additions & 1 deletion Sources/ParameterizedTesting/ParameterizedTestsCase1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class ParameterizedTestCase1<IN1, OUT>: XCTestCase {
{ value1 in

let selector = ParameterizedTestCase1.registerTestMethod(
name: "\(value1)".lowercased(),
name: testName(value1),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -56,6 +56,10 @@ open class ParameterizedTestCase1<IN1, OUT>: XCTestCase {
nil
}

open class func testName(_ value1: IN1) -> String {
"\(value1)".lowercased()
}

open func testAllCombinations(_ value1: IN1, _ expectedResult: OUT?) {
fatalError("Not implemented")
}
Expand Down
9 changes: 8 additions & 1 deletion Sources/ParameterizedTesting/ParameterizedTestsCase2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open class ParameterizedTestCase2<IN1, IN2, OUT>: XCTestCase {
{ value1, value2 in

let selector = ParameterizedTestCase2.registerTestMethod(
name: "\(value1)_\(value2)".lowercased(),
name: testName(value1, value2),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -58,6 +58,13 @@ open class ParameterizedTestCase2<IN1, IN2, OUT>: XCTestCase {
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2
) -> String {
"\(value1)_\(value2)".lowercased()
}

open func testAllCombinations(_ value1: IN1, _ value2: IN2, _ expectedResult: OUT?) {
fatalError("Not implemented")
}
Expand Down
10 changes: 9 additions & 1 deletion Sources/ParameterizedTesting/ParameterizedTestsCase3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open class ParameterizedTestCase3<IN1, IN2, IN3, OUT>: XCTestCase {
{ value1, value2, value3 in

let selector = ParameterizedTestCase3.registerTestMethod(
name: "\(value1)_\(value2)_\(value3)".lowercased(),
name: testName(value1, value2, value3),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -60,6 +60,14 @@ open class ParameterizedTestCase3<IN1, IN2, IN3, OUT>: XCTestCase {
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2,
_ value3: IN3
) -> String {
"\(value1)_\(value2)_\(value3)".lowercased()
}

open func testAllCombinations(_ value1: IN1, _ value2: IN2, _ value3: IN3, _ expectedResult: OUT?) {
fatalError("Not implemented")
}
Expand Down
11 changes: 10 additions & 1 deletion Sources/ParameterizedTesting/ParameterizedTestsCase4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class ParameterizedTestCase4<IN1, IN2, IN3, IN4, OUT>: XCTestCase {
{ value1, value2, value3, value4 in

let selector = ParameterizedTestCase4.registerTestMethod(
name: "\(value1)_\(value2)_\(value3)_\(value4)".lowercased(),
name: testName(value1, value2, value3, value4),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -62,6 +62,15 @@ open class ParameterizedTestCase4<IN1, IN2, IN3, IN4, OUT>: XCTestCase {
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2,
_ value3: IN3,
_ value4: IN4
) -> String {
"\(value1)_\(value2)_\(value3)_\(value4)".lowercased()
}

open func testAllCombinations(
_ value1: IN1,
_ value2: IN2,
Expand Down
12 changes: 11 additions & 1 deletion Sources/ParameterizedTesting/ParameterizedTestsCase5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class ParameterizedTestCase5<IN1, IN2, IN3, IN4, IN5, OUT>: XCTestCase {
{ value1, value2, value3, value4, value5 in

let selector = ParameterizedTestCase5.registerTestMethod(
name: "\(value1)_\(value2)_\(value3)_\(value4)_\(value5)".lowercased(),
name: testName(value1, value2, value3, value4, value5),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -64,6 +64,16 @@ open class ParameterizedTestCase5<IN1, IN2, IN3, IN4, IN5, OUT>: XCTestCase {
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2,
_ value3: IN3,
_ value4: IN4,
_ value5: IN5
) -> String {
"\(value1)_\(value2)_\(value3)_\(value4)_\(value5)".lowercased()
}

open func testAllCombinations(
_ value1: IN1,
_ value2: IN2,
Expand Down
13 changes: 12 additions & 1 deletion Sources/ParameterizedTesting/ParameterizedTestsCase6.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class ParameterizedTestCase6<IN1, IN2, IN3, IN4, IN5, IN6, OUT>: XCTestCase
{ value1, value2, value3, value4, value5, value6 in

let selector = ParameterizedTestCase6.registerTestMethod(
name: "\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)".lowercased(),
name: testName(value1, value2, value3, value4, value5, value6),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -67,6 +67,17 @@ open class ParameterizedTestCase6<IN1, IN2, IN3, IN4, IN5, IN6, OUT>: XCTestCase
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2,
_ value3: IN3,
_ value4: IN4,
_ value5: IN5,
_ value6: IN6
) -> String {
"\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)".lowercased()
}

open func testAllCombinations(
_ value1: IN1,
_ value2: IN2,
Expand Down
14 changes: 13 additions & 1 deletion Sources/ParameterizedTesting/ParameterizedTestsCase7.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ open class ParameterizedTestCase7<IN1, IN2, IN3, IN4, IN5, IN6, IN7, OUT>: XCTes
{ value1, value2, value3, value4, value5, value6, value7 in

let selector = ParameterizedTestCase7.registerTestMethod(
name: "\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)_\(value7)".lowercased(),
name: testName(value1, value2, value3, value4, value5, value6, value7),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -69,6 +69,18 @@ open class ParameterizedTestCase7<IN1, IN2, IN3, IN4, IN5, IN6, IN7, OUT>: XCTes
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2,
_ value3: IN3,
_ value4: IN4,
_ value5: IN5,
_ value6: IN6,
_ value7: IN7
) -> String {
"\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)_\(value7)".lowercased()
}

open func testAllCombinations(
_ value1: IN1,
_ value2: IN2,
Expand Down
16 changes: 14 additions & 2 deletions Sources/ParameterizedTesting/ParameterizedTestsCase8.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ open class ParameterizedTestCase8<IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, OUT>:
{ value1, value2, value3, value4, value5, value6, value7, value8 in

let selector = ParameterizedTestCase8.registerTestMethod(
name: "\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)_\(value7)_\(value8)"
.lowercased(),
name: testName(value1, value2, value3, value4, value5, value6, value7, value8),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -72,6 +71,19 @@ open class ParameterizedTestCase8<IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, OUT>:
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2,
_ value3: IN3,
_ value4: IN4,
_ value5: IN5,
_ value6: IN6,
_ value7: IN7,
_ value8: IN8
) -> String {
"\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)_\(value7)_\(value8)".lowercased()
}

open func testAllCombinations(
_ value1: IN1,
_ value2: IN2,
Expand Down
17 changes: 15 additions & 2 deletions Sources/ParameterizedTesting/ParameterizedTestsCase9.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ open class ParameterizedTestCase9<IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, O
{ value1, value2, value3, value4, value5, value6, value7, value8, value9 in

let selector = ParameterizedTestCase9.registerTestMethod(
name: "\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)_\(value7)_\(value8)_\(value9)"
.lowercased(),
name: testName(value1, value2, value3, value4, value5, value6, value7, value8, value9),
testMethod: #selector(self.internalHandler)
)

Expand Down Expand Up @@ -74,6 +73,20 @@ open class ParameterizedTestCase9<IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, O
nil
}

open class func testName(
_ value1: IN1,
_ value2: IN2,
_ value3: IN3,
_ value4: IN4,
_ value5: IN5,
_ value6: IN6,
_ value7: IN7,
_ value8: IN8,
_ value9: IN9
) -> String {
"\(value1)_\(value2)_\(value3)_\(value4)_\(value5)_\(value6)_\(value7)_\(value8)_\(value9)".lowercased()
}

open func testAllCombinations(
_ value1: IN1,
_ value2: IN2,
Expand Down

0 comments on commit c102bac

Please sign in to comment.