In unit testing I want to create mock object for factory classes e.g.


but I have following error,

generation does not exist.

So how to generate factory class in in generation when create unit testing.


You can do it like this,

$rowFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RawFactory::class)

        $rawResult = $this


First, you need to create mock of RawFactory class then you need to create mock Raw class and last you need to assign $rawResult to $rowFactoryMock

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.