Required Configuration for integration testing
All Magento integration test code can be found in
dev/tests
├── integration
├──etc
├──install-config-mysql.php.dist
├──phpunit.xml
Step1:
/dev/tests/integration/etc/install-config-mysql.php.dist. Copy this file to /dev/tests/integration/etc/install-config-mysql.php
database credentials in the above file. Use different database name because in integration testingall database is rest.
Copy this file dev/tests/integration/phpunit.xml.dist to dev/tests/integration/phpunit.xml
Replace to
Step2:
And Create file inside BaseConfigTest.php NameSpace\module\Test\Integration
Now go to Project root folder and run command
../../../vendor/bin/phpunit --testsuite "Namespace Modulename"
Or
../../../vendor/phpunit/phpunit/phpunit --testsuite "Namespace Modulename"
If TESTS_CLEANUP is enabled then it reset database if it is disabled then it run from existing state
All Magento integration test code can be found in
dev/tests
├── integration
├──etc
├──install-config-mysql.php.dist
├──phpunit.xml
Step1:
/dev/tests/integration/etc/install-config-mysql.php.dist. Copy this file to /dev/tests/integration/etc/install-config-mysql.php
database credentials in the above file. Use different database name because in integration testingall database is rest.
Copy this file dev/tests/integration/phpunit.xml.dist to dev/tests/integration/phpunit.xml
<testsuite name="Magento Integration Tests">
<directory suffix="Test.php">testsuite</directory>
<exclude>testsuite/Magento/MemoryUsageTest.php</exclude>
</testsuite>
Replace to
<testsuite name="Namespace Modulename">
<directory suffix="Test.php">../../../app/code/*/*/Test/Integration</directory>
<exclude>testsuite/Magento/MemoryUsageTest.php</exclude>
</testsuite>
Step2:
And Create file inside BaseConfigTest.php NameSpace\module\Test\Integration
namespace NameSpace\module\Test\Integration;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\DeploymentConfig\Reader as DeploymentConfigReader;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Module\ModuleList;
use Magento\TestFramework\ObjectManager;
class BaseConfigTest extends \PHPUnit\Framework\TestCase
{
private $moduleName = 'Namespace_ModuleName';
private $objectManager;
public function testTheModuleIsRegistered()
{
$registrar = new ComponentRegistrar();
$path = $registrar->getPaths(ComponentRegistrar::MODULE);
$this->assertArrayHasKey($this->moduleName, $path);
}
protected function setUp()
{
$this->objectManager = ObjectManager::getInstance();
}
}
Now go to Project root folder and run command
../../../vendor/bin/phpunit --testsuite "Namespace Modulename"
Or
../../../vendor/phpunit/phpunit/phpunit --testsuite "Namespace Modulename"
Comments
Post a Comment