我有个Laravel项目。
我想在我的开发机器+ Travis/Scrutinizer上使用SQLite进行测试,另外我想在另一台使用MySQL的机器上进行测试。
这是我的PHPUnit文件,它的工作方式很简单
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<logging>
<!-- and this is where your report will be written -->
<log type="coverage-clover" target="./logs/clover.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>我在问:是否有可能在linux shell命令上启动类似的命令(当然是伪代码):
./vendor/bin/phpunit --db_connection=mysql发布于 2019-02-13 19:29:33
默认情况下,不能从命令行动态编辑phpunit.xml文件,但可以像这样设置DB_CONNECTION环境变量(和其他变量):
DB_CONNECTION=mysql ./vendor/bin/phpunit
您可以在this answer中查看用于设置环境变量的更多选项。
https://stackoverflow.com/questions/54668288
复制相似问题