diff --git a/Sources/XCTest/Private/TestListing.swift b/Sources/XCTest/Private/TestListing.swift index a3dfe9ba1..1dfb6a856 100644 --- a/Sources/XCTest/Private/TestListing.swift +++ b/Sources/XCTest/Private/TestListing.swift @@ -52,7 +52,7 @@ protocol Listable { } private func moduleName(value: Any) -> String { - let moduleAndType = String(reflecting: value.dynamicType) + let moduleAndType = String(reflecting: type(of: value)) return String(moduleAndType.characters.split(separator: ".").first!) } @@ -63,7 +63,7 @@ extension XCTestSuite: Listable { } private var listingName: String { - if let childTestCase = tests.first as? XCTestCase, name == String(describing: childTestCase.dynamicType) { + if let childTestCase = tests.first as? XCTestCase, name == String(describing: type(of: childTestCase)) { return "\(moduleName(value: childTestCase)).\(name)" } else { return name diff --git a/Sources/XCTest/Private/WallClockTimeMetric.swift b/Sources/XCTest/Private/WallClockTimeMetric.swift index 1a000e748..459534a4a 100644 --- a/Sources/XCTest/Private/WallClockTimeMetric.swift +++ b/Sources/XCTest/Private/WallClockTimeMetric.swift @@ -44,7 +44,7 @@ internal final class WallClockTimeMetric: PerformanceMetric { String(format: "average: %.3f", measurements.average), String(format: "relative standard deviation: %.3f%%", measurements.relativeStandardDeviation), "values: [\(measurements.map({ String(format: "%.6f", $0) }).joined(separator: ", "))]", - "performanceMetricID:\(self.dynamicType.name)", + "performanceMetricID:\(type(of: self).name)", String(format: "maxPercentRelativeStandardDeviation: %.3f%%", maxRelativeStandardDeviation), String(format: "maxStandardDeviation: %.3f", standardDeviationNegligibilityThreshold), ] diff --git a/Sources/XCTest/Public/XCTestCase+Performance.swift b/Sources/XCTest/Public/XCTestCase+Performance.swift index 8578fe914..5b9548af9 100644 --- a/Sources/XCTest/Public/XCTestCase+Performance.swift +++ b/Sources/XCTest/Public/XCTestCase+Performance.swift @@ -50,7 +50,7 @@ public extension XCTestCase { /// ensure compatibility of tests between swift-corelibs-xctest and Apple /// XCTest, it is not recommended to pass explicit values for `file` and `line`. func measure(file: StaticString = #file, line: UInt = #line, block: () -> Void) { - measureMetrics(self.dynamicType.defaultPerformanceMetrics(), + measureMetrics(type(of: self).defaultPerformanceMetrics(), automaticallyStartMeasuring: true, file: file, line: line, @@ -66,7 +66,7 @@ public extension XCTestCase { /// may interfere the API will measure them separately. /// /// func testMyFunction2_WallClockTime() { - /// measureMetrics(self.dynamicType.defaultPerformanceMetrics(), automaticallyStartMeasuring: false) { + /// measureMetrics(type(of: self).defaultPerformanceMetrics(), automaticallyStartMeasuring: false) { /// /// // Do setup work that needs to be done for every iteration but /// // you don't want to measure before the call to `startMeasuring()` diff --git a/Sources/XCTest/Public/XCTestCase.swift b/Sources/XCTest/Public/XCTestCase.swift index 82d146b82..202ad1fd8 100644 --- a/Sources/XCTest/Public/XCTestCase.swift +++ b/Sources/XCTest/Public/XCTestCase.swift @@ -90,7 +90,7 @@ public class XCTestCase: XCTest { /// `-[XCTestCase initWithInvocation:]`, it's rare for anyone outside of /// XCTest itself to call this initializer. public required init(name: String, testClosure: @escaping (XCTestCase) throws -> Void) { - _name = "\(self.dynamicType).\(name)" + _name = "\(type(of: self)).\(name)" self.testClosure = testClosure } @@ -179,7 +179,7 @@ public func testCase(_ allTests: [(String, (T) -> () -> Void)]) - private func test(_ testFunc: @escaping (T) -> () throws -> Void) -> (XCTestCase) throws -> Void { return { testCaseType in guard let testCase = testCaseType as? T else { - fatalError("Attempt to invoke test on class \(T.self) with incompatible instance type \(testCaseType.dynamicType)") + fatalError("Attempt to invoke test on class \(T.self) with incompatible instance type \(type(of: testCaseType))") } try testFunc(testCase)()