It's easy to enable Metal API validation when running my app via Edit Scheme -> Run -> Options -> Metal API Validation: Xcode logging: "Metal API Validation Enabled"
But what about for testing? There is no such setting in Edit Scheme -> Test, and validation appears to be off when I run tests.
Set the METAL_DEVICE_WRAPPER_TYPE environment variable to 1 in Edit Scheme -> Test -> Arguments.