ho-nl / magento2-ReachDigital_TestFramework

Faster drop-in replacement for Magento's integration test.
MIT License
75 stars 13 forks source link

Run tests through phpunit directly? #6

Closed peterjaap closed 4 years ago

peterjaap commented 5 years ago

I'm trying to run the tests through phpunit directly instead of having it called through bin/magento dev:tests:run integration.

Because when I run bin/magento dev:tests:run integration I see it still runs the normal integration tests;

$ php bin/magento dev:tests:run integration       

---- /data/client/magento2/dev/tests/integration> /usr/local/bin/php /data/client/magento2/./vendor/phpunit/phpunit/phpunit  

PHPUnit 6.2.4 by Sebastian Bergmann and contributors.

... etc

So I'm running cd dev/tests/quick-integration; php ../../../vendor/phpunit/phpunit/phpunit.

I then get PHP Fatal error: Uncaught Error: Class 'Magento\TestFramework\Bootstrap\Settings' not found in dev/tests/quick-integration/framework/bootstrap.php:28.

Is it even possible to run it from the quick-integration dir directly? And if so, it seems the autoloader doesn't work?

Vinai commented 5 years ago

Maybe try running the integration tests from within the regular integration test directory but with the quick-integration phpunit.xml file.

cd dev/tests/integration; php ../../../vendor/bin/phpunit -c ../quick-integration/phpunit.xml

What works for sure is using absolute directory paths:

php $(pwd)/vendor/bin/phpunit -c $(pwd)/dev/tests/quick-integration/phpunit.xml [tests-to-run]

peterjaap commented 5 years ago

Yep that works, thanks!

peterjaap commented 4 years ago

@vinai weirdly enough, on my new machine I can't get it to work anymore;

app@1e7c7bc921fc:~/client/magento2$ php /data/client/magento2/vendor/bin/phpunit -c /data/client/magento2/dev/tests/quick-integration/phpunit.xml 
PHP Fatal error:  Uncaught Error: Class 'Magento\TestFramework\Bootstrap\Settings' not found in /data/client/magento2/dev/tests/quick-integration/framework/bootstrap.php:28
Stack trace:
#0 /data/client/magento2/vendor/phpunit/phpunit/src/Util/Fileloader.php(64): include_once()
#1 /data/client/magento2/vendor/phpunit/phpunit/src/Util/Fileloader.php(48): PHPUnit\Util\Fileloader::load('/data/client...')
#2 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(991): PHPUnit\Util\Fileloader::checkAndLoad('/data/client...')
#3 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(788): PHPUnit\TextUI\Command->handleBootstrap('/data/client...')
#4 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(159): PHPUnit\TextUI\Command->handleArguments(Array)
#5 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(148): PHPUnit\TextUI\Command->run(Array, true)
#6 /data/client/magento2/vendor/phpunit/phpunit/phpunit(53): PHPUnit\TextUI\Command::main()
# in /data/client/magento2/dev/tests/quick-integration/framework/bootstrap.php on line 28

Fatal error: Uncaught Error: Class 'Magento\TestFramework\Bootstrap\Settings' not found in /data/client/magento2/dev/tests/quick-integration/framework/bootstrap.php:28
Stack trace:
#0 /data/client/magento2/vendor/phpunit/phpunit/src/Util/Fileloader.php(64): include_once()
#1 /data/client/magento2/vendor/phpunit/phpunit/src/Util/Fileloader.php(48): PHPUnit\Util\Fileloader::load('/data/client...')
#2 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(991): PHPUnit\Util\Fileloader::checkAndLoad('/data/client...')
#3 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(788): PHPUnit\TextUI\Command->handleBootstrap('/data/client...')
#4 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(159): PHPUnit\TextUI\Command->handleArguments(Array)
#5 /data/client/magento2/vendor/phpunit/phpunit/src/TextUI/Command.php(148): PHPUnit\TextUI\Command->run(Array, true)
#6 /data/client/magento2/vendor/phpunit/phpunit/phpunit(53): PHPUnit\TextUI\Command::main()
# in /data/client/magento2/dev/tests/quick-integration/framework/bootstrap.php on line 28

Magento 2.3.3 installation, maybe something changed?

Tjitse-E commented 4 years ago

@peterjaap maybe try to apply commit https://github.com/ho-nl/magento2-ReachDigital_TestFramework/commit/73c464f41c965c60913ee5b665b6d616c18f68fb? This fix isn't in the latest release yet.

PascalBrouwers commented 4 years ago

@peterjaap does it work with the latest version again?

peterjaap commented 4 years ago

@PascalBrouwers nope, now getting:

app@8c72f0842b28:~/clientname/magento2$ php /data/clientname/magento2/vendor/bin/phpunit -c /data/clientname/magento2/dev/tests/quick-integration/phpunit.xml 
PHP Fatal error:  Uncaught Error: Cannot instantiate interface Magento\Framework\Cache\FrontendInterface in /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50
Stack trace:
#0 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#1 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(167): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#2 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(273): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'cache', 'Magento\\Framewo...')
#3 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument('Magento\\Framewo...', Array, Array)
#4 /data/clie in /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 50

Fatal error: Uncaught Error: Cannot instantiate interface Magento\Framework\Cache\FrontendInterface in /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50
Stack trace:
#0 /data/clientname/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#1 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(167): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#2 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(273): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Framewo...', NULL, 'cache', 'Magento\\Framewo...')
#3 /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument('Magento\\Framewo...', Array, Array)
#4 /data/clie in /data/clientname/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php on line 50
PHP Fatal error:  Uncaught Exception: sh: 1: tasklist.exe: not found in /data/clientname/magento2/vendor/magento/framework/Shell.php:63
Stack trace:
#0 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php(92): Magento\Framework\Shell->execute('tasklist.exe /f...', Array)
#1 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php(58): Magento\TestFramework\Helper\Memory->_getWinProcessMemoryUsage(7)
#2 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/MemoryLimit.php(127): Magento\TestFramework\Helper\Memory->getRealMemoryUsage()
#3 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/MemoryLimit.php(59): Magento\TestFramework\MemoryLimit->_getUsage()
#4 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/Bootstrap/Memory.php(50): Magento\TestFramework\MemoryLimit->printStats()
#5 [internal function]: Magento\TestFramework\Bootstrap\Memory->displayStats()
#6 {main} in /data/clientname/magento2/vendor/magento/framework/Shell.php on line 64

Fatal error: Uncaught Exception: sh: 1: tasklist.exe: not found in /data/clientname/magento2/vendor/magento/framework/Shell.php:63
Stack trace:
#0 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php(92): Magento\Framework\Shell->execute('tasklist.exe /f...', Array)
#1 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php(58): Magento\TestFramework\Helper\Memory->_getWinProcessMemoryUsage(7)
#2 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/MemoryLimit.php(127): Magento\TestFramework\Helper\Memory->getRealMemoryUsage()
#3 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/MemoryLimit.php(59): Magento\TestFramework\MemoryLimit->_getUsage()
#4 /data/clientname/magento2/dev/tests/integration/framework/Magento/TestFramework/Bootstrap/Memory.php(50): Magento\TestFramework\MemoryLimit->printStats()
#5 [internal function]: Magento\TestFramework\Bootstrap\Memory->displayStats()
#6 {main} in /data/clientname/magento2/vendor/magento/framework/Shell.php on line 64
peterjaap commented 4 years ago

@PascalBrouwers looked at it again but I have no clue why it gives the above notice.

paales commented 4 years ago

Should be in readme now