我想根据“ --skip-group”设置在不同的环境/阶段以不同的断言运行Codeception CEST测试,因为基于此设置,还有一些完整的测试会被跳过:
seeInDatabase
进行防御性很强/严格的断言我尝试过:
基于http://phptest.club/t/condition-in-my-function-for-skip-group-onlyondev/858/2:
$this->options
似乎不可用(Codeception 2.5.1);但也许我犯了一些错误?对诸如\Codeception\Scenario
这样的Codeception代码的幼稚研究似乎并未解决我的担忧
这些是我现在重复的测试,我只想替换为带有条件调用seeFormSubmissionInDatabase
的测试(请参阅“ //!HERE”)
/**
* @param Front\Forms\ContactForm\PageObject $contactFormPage
* @group nonProductionTest
*/
public function submitContactFormSuccessful(Front\Forms\ContactForm\PageObject $contactFormPage) {
$firstName = 'User' . uniqid();
$contactFormPage->openPage();
$contactFormPage->fillFormWithValidData($firstName);
$contactFormPage->fillFormWithPrivacyAcceptance();
$contactFormPage->submitForm();
$contactFormPage->seeValidFormSubmission();
// TODO: instead of "@group nonProductionTest" for test and duplication submitContactFormSuccessfulWithoutDb()
// if not group skip nonProductionTest then also check
$contactFormPage->seeFormSubmissionInDatabase($firstName); // ! HERE
}
/**
* TODO: Duplication of submitContactFormSuccessful() test above
* @param Front\Forms\ContactForm\PageObject $contactFormPage
*/
public function submitContactFormSuccessfulWithoutDb(Front\Forms\ContactForm\PageObject $contactFormPage) {
$firstName = 'User' . uniqid();
$contactFormPage->openPage();
$contactFormPage->fillFormWithValidData($firstName);
$contactFormPage->fillFormWithPrivacyAcceptance();
$contactFormPage->submitForm();
$contactFormPage->seeValidFormSubmission();
}