public function testExecuteWithException() { $customersIds = [10, 11, 12]; $this->customerCollectionMock->expects($this->any())->method('getAllIds')->willReturn($customersIds); $this->customerRepositoryMock->expects($this->any())->method('getById')->willThrowException(new \Exception('Some message.')); $this->messageManagerMock->expects($this->once())->method('addError')->with('Some message.'); $this->massAction->execute(); }