我想为不同的代码检测测试执行不同的转储文件。现在正在从 shell_exec
执行 Db 转储文件命令 _before
AcceptanceHelper
的方法| ,在每次验收测试之前执行。像建议的东西 here .应用程序中有很多测试。所以,流程如下
- tests/acceptance/application/<contains alot of tests related to application>
- tests/acceptance/location/<contains alot of tests related to location>
两个测试目录/application/
和 /location/
使用相同的 AcceptanceHelper
.所以,我想要的是一个不同的可执行转储文件,用于 /application/
中的所有测试。目录比/location/
测试。
想想像 Get current running test name 这样的东西.比方说 application_dump.sql
/application/
内的所有测试目录和 location_dump.sql
/location/
内的所有测试目录。
P.S: Using a different suite for application and location is ideally not what i am looking for.
最佳答案
只是为了帮助一些人。因为没有合适的方法来实现这一点 Get current running test name似乎仍在开发中。
所以,这就是我设法解决问题的方法。我已将 shell_exec
命令移出 AcceptanceHelper
的 _before
方法,并在 AcceptanceHelper
中创建了一个新的公共(public)方法,它可以是在每次验收测试中通过 actor 类 $I
访问
$I->executeDbDump('application_dump.sql');
$I->executeDbDump('location_dump.sql');
使用这种方法的唯一缺点是我必须在每次测试之前手动执行相应的 executeDbDump
函数。但现在似乎仍然是解决该问题的最佳方法。
关于php - 在 codeception acceptance helper 中动态执行 DB dump,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28253877/