diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index b9df4f0fdf40ab..9ca065238b4dd3 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -912,7 +912,8 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray *> * data) { + for (NSDictionary * attributeReponseValue in data) { + if (attributeReponseValue[MTRErrorKey]) { + [attributeReportErrorExpectation fulfill]; + } + } + }; + // use the nonexistent attribute and expect read error + [device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:nil]; + [self waitForExpectations:@[ attributeReportErrorExpectation ] timeout:10]; + // reset the onAttributeDataReceived to validate the following resubscribe test delegate.onAttributeDataReceived = ^(NSArray *> * data) { attributeReportsReceived += data.count;