php - 在 codeception acceptance helper 中动态执行 DB dump

标签 php testing codeception

我想为不同的代码检测测试执行不同的转储文件。现在正在从 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/

相关文章:

xpath - Codeception - 单击没有 id 的 HREF

php - 学说 : Default value on joinColumn field

php - 在 Plesk 中运行 Laravel 5.1 任务计划程序

php - 使用php和mysql计算两点之间的距离

testing - 通过具体类测试抽象类

Codeception,如何从命令行覆盖特定(或非特定)套件测试的 url?

php - 在 codeception 中丢失 session /cookies - 我怎样才能保持登录到我的网站?

php - 带有 AddHandler php5-script .php 行的 .htaccess 有什么作用?

testing - 如何正确测试ngrx 4中的效果?

testing - 如何测试n个元素的栈?