magento2: Class 'PHPUnit\Framework\TestCase' not found when execute UnitTests

Preconditions

  1. Magento Open Source 2.2

Steps to reproduce

  1. Install Magento 2.2
  2. enter Terminal in Document Root of Magento 2.2
  3. execute ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist

Expected result

  1. the tests are running

Actual result

1.Class ‘PHPUnit\Framework\TestCase’ not found in /var/www/htdocs/setup/src/Magento/Setup/Test/Unit/Console/Command/AdminUserCreateCommandTest.php on line 14 image

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

@jigar48 If you’re using PHPUnit version 6, please replace class ‘PHPUnit_Framework_TestCase’ in your test file to ‘PHPUnit\Framework\TestCase’. So it’d look like this:

class YourTest extends \PHPUnit\Framework\TestCase {
    ...
}

Looks like you forgot to run composer install.

In 2.2.0 PHPUnit version was upgraded to 6.x which introduced this new class.