/** * Run test execute method (fail generate label) */ public function testExecuteLabelGenerateFail() { $this->shipmentLoaderMock->expects($this->once()) ->method('load') ->will($this->returnValue($this->shipmentMock)); $this->labelGenerator->expects($this->once()) ->method('create') ->with($this->shipmentMock, $this->requestMock) ->willThrowException( new \Magento\Framework\Exception\LocalizedException(__('message')) ); $this->responseMock->expects($this->once())->method('representJson'); $this->assertNull($this->controller->executeInternal()); }