Skip to content

Commit

Permalink
[monotouch-test] Teach HealthKit tests about new HKQuantityTypeIdenti…
Browse files Browse the repository at this point in the history
…fiers/HKCategoryTypeIdentifiers. (#12317)

Fixes these test failures:

    MonoTouchFixtures.HealthKit.CategoryTypeIdentifier
    	[FAIL] EnumValues_22351 : AppleWalkingSteadinessEvent could not be created: System.ArgumentNullException: Value cannot be null.
    Parameter name: hkCategoryTypeIdentifier
      at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x00003] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:27
      at HealthKit.HKObjectType.GetCategoryType (Foundation.NSString hkCategoryTypeIdentifier) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/HealthKit/HKObjectType.g.cs:111
      at HealthKit.HKCategoryType.Create (HealthKit.HKCategoryTypeIdentifier kind) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/HealthKit/HKObjectType.cs:26
      at MonoTouchFixtures.HealthKit.CategoryTypeIdentifier.EnumValues_22351 () [0x001fd] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs:115
      at MonoTouchFixtures.HealthKit.CategoryTypeIdentifier.EnumValues_22351 () [0x0024f] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs:120

    MonoTouchFixtures.HealthKit.QuantityTypeIdentifier
    	[FAIL] EnumValues_22351 : AppleWalkingSteadiness could not be created: System.ArgumentNullException: Value cannot be null.
    Parameter name: hkTypeIdentifier
      at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x00003] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:27
      at HealthKit.HKObjectType.GetQuantityType (Foundation.NSString hkTypeIdentifier) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/HealthKit/HKObjectType.g.cs:162
      at HealthKit.HKQuantityType.Create (HealthKit.HKQuantityTypeIdentifier kind) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/HealthKit/HKObjectType.cs:19
      at MonoTouchFixtures.HealthKit.QuantityTypeIdentifier.EnumValues_22351 () [0x0017a] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs:87
      at MonoTouchFixtures.HealthKit.QuantityTypeIdentifier.EnumValues_22351 () [0x001cc] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs:92

Also make these tests show all failing enum values at once, instead of having
to run the test after adding each new case.
  • Loading branch information
rolfbjarne committed Aug 2, 2021
1 parent cbc6989 commit d506a13
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 12 additions & 1 deletion tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#if HAS_HEALTHKIT

using System;
using System.Collections.Generic;

using Foundation;
using HealthKit;
Expand All @@ -27,6 +28,8 @@ public void EnumValues_22351 ()
{
TestRuntime.AssertXcodeVersion (6, 0);

var failures = new List<string> ();

foreach (HKCategoryTypeIdentifier value in Enum.GetValues (typeof (HKCategoryTypeIdentifier))) {

switch (value) {
Expand Down Expand Up @@ -105,6 +108,12 @@ public void EnumValues_22351 ()
if (!TestRuntime.CheckXcodeVersion (12, 3))
continue;
break;
case HKCategoryTypeIdentifier.AppleWalkingSteadinessEvent:
case HKCategoryTypeIdentifier.PregnancyTestResult:
case HKCategoryTypeIdentifier.ProgesteroneTestResult:
if (!TestRuntime.CheckXcodeVersion (13, 0))
continue;
break;
default:
if (!TestRuntime.CheckXcodeVersion (7, 0))
continue;
Expand All @@ -117,9 +126,11 @@ public void EnumValues_22351 ()
}
}
catch (Exception e) {
Assert.Fail ("{0} could not be created: {1}", value, e);
failures.Add ($"{value} could not be created: {e}");
}
}

Assert.That (failures, Is.Empty, "No failures");
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#if HAS_HEALTHKIT

using System;
using System.Collections.Generic;

using Foundation;
using HealthKit;
Expand All @@ -27,6 +28,8 @@ public void EnumValues_22351 ()
{
TestRuntime.AssertXcodeVersion (6, 0);

var failures = new List<string> ();

foreach (HKQuantityTypeIdentifier value in Enum.GetValues (typeof (HKQuantityTypeIdentifier))) {

// we need to have version checks for anything added after iOS 8.0
Expand Down Expand Up @@ -81,6 +84,11 @@ public void EnumValues_22351 ()
if (!TestRuntime.CheckXcodeVersion (12, 5))
continue;
break;
case HKQuantityTypeIdentifier.AppleWalkingSteadiness:
case HKQuantityTypeIdentifier.NumberOfAlcoholicBeverages:
if (!TestRuntime.CheckXcodeVersion (13, 0))
continue;
break;
}

try {
Expand All @@ -89,9 +97,11 @@ public void EnumValues_22351 ()
}
}
catch (Exception e) {
Assert.Fail ("{0} could not be created: {1}", value, e);
failures.Add ($"{value} could not be created: {e}");
}
}

Assert.That (failures, Is.Empty, "No failures");
}
}
}
Expand Down

1 comment on commit d506a13

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on Build (no summary found). 🔥

Result file $(TEST_SUMMARY_PATH) not found.

Pipeline on Agent
[monotouch-test] Teach HealthKit tests about new HKQuantityTypeIdentifiers/HKCategoryTypeIdentifiers. (#12317)

Please sign in to comment.