I tried to make a unit test for my custom module like this:
app/code/MyCompany/UnitTest/Test/Unit/Controller/SpinTest.php
namespace MyCompany\UnitTest\Controller;
class SpinTest extends \Magento\TestFramework\TestCase\AbstractController
{
public function testLogin()
{
$params = [
'customer_id' => '3'
];
$this->getRequest()->setPostValue($params);
$this->dispatch('spin/run');
$result = $this->getResponse()->getBody();
$this->assertEquals('200', $result['status']);
}
}
And ran the unit from terminal:
vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/MyCompany/UnitTest/Test/Unit/Controller/
But i got an error like this:
Class 'Magento\TestFramework\TestCase\AbstractController' not found in /var/www/mage2/app/code/MyCompany/UnitTest/Test/Unit/Controller/SpinTest.php on line 4