Does Swift Testing support using ‘any’ values as parameters like seen here for ‘any ChartDataPoint.Type’
@Test(arguments: [
(expectedBodyFatValues,
HKQuantityTypeIdentifier.bodyFatPercentage,
HKUnit.percent(),
BodyFatPoint.self),
(expectedActiveEnergyValues,
HKQuantityTypeIdentifier.activeEnergyBurned,
HKUnit.kilocalorie(),
ActiveCaloriesPoint.self),
(expectedBodyMassValues,
HKQuantityTypeIdentifier.bodyMass,
HKUnit.pound(),
BodyMassPoint.self),
(expectedBasalEnergyValues,
HKQuantityTypeIdentifier.basalEnergyBurned,
HKUnit.kilocalorie(),
BasalEnergyPoint.self)
])
func healthKitDataReading(
expectedData: [Double],
identifier: HKQuantityTypeIdentifier,
unit: HKUnit,
dataChartType: any ChartDataPoint.Type
) async throws {...}
Currently I can’t get this code to work, and see the error
… Conflicting arguments to generic parameter 'C' ('[([Double], HKQuantityTypeIdentifier, HKUnit, BodyFatPoint.Type)]' vs. '[([Double], HKQuantityTypeIdentifier, HKUnit, ActiveCaloriesPoint.Type)]' vs. '[([Double], HKQuantityTypeIdentifier, HKUnit, BodyMassPoint.Type)]' vs. '[([Double], HKQuantityTypeIdentifier, HKUnit, BasalEnergyPoint.Type)]')
Also, I can’t seem to use variables like ‘expectedBodyFatValues’ due to the error
Instance member 'expectedBodyFatValues' cannot be used on type 'Health_Mix_Swift_Tests'; did you mean to use a value of this type instead?
Only way I’ve found around this is including the entire array of values as the parameter, but it’s very cumbersome.