防止方法在测试期间被执行 Codeception

Prevent a method from being executed during tests Codeception

当我在终端上执行 codecept run 时,我执行了所有测试。我想禁止执行一种特定方法。

Api Tests (6) ---------------------------------------------------------------------
✔ ...Cest: It_should_deny_access_to_anonymous_user (1.112s)
✔ ...Cest: It_should_deny_access_to_unauthorized_user (0.26s)
✔ ...Cest: It_should_deny_access_to_host_without_any_user (0.22s)
✔ ...Cest: It_should_access_firewall_settings_with_authorized_user (0.28s)
✔ ...Cest: Token (0.21s)
✔ ...Cest: It_should_create_new_firewall_setting (0.5s)

名为 Token 的方法实际上属于我的测试 Class 使用的 Trait

class FirewallSettingsAuthorizationCest {

    use MakeTokens;

    ...
}

如何阻止该特征中的方法作为测试执行?

一般情况下,如何编写不会被 Codeception 测试的方法?

"Each public method of Cest (except those starting with _) will be executed as a test"

因此要编写一个不会被测试的方法,您可以尝试更改方法可见性(如果可能)或在方法名称前加上下划线 (_)。

来源:http://codeception.com/docs/07-AdvancedUsage