1
특정 수주로 실행해야하는 수락 테스트가 여러 개 있습니다. 그들은 서로 의지하기 때문에. 지금 어떻게 내가 거기에서 그것을 실행할 수 있도록 내가 원하는 순서로 실행되도록 createstore 클래스에서 tryToCreateACollection을 호출합니까.코드 생성 : 다른 수락 테스트에서 메서드 호출
class CreateStoreCest
{
public function _before(AcceptanceTester $I)
{
$I->amOnPage('http://127.0.0.1:8000/login');
$I->submitForm('[name="login"]', [
'_username' => 'test',
'_password' => 'test12']);
$I->dontSee('Invalid credentials.');
}
public function tryToCreateAStore(AcceptanceTester $I)
{
$I->wantTo('I create a store');
$I->click('//*[@id="dropdown-webshop"]/li[3]/a');
$I->see('Account information');
$I->submitForm('[name="user"]', [
'user[first_name]' => 'TestUserFirstName',
'user[last_name]' => 'TestUserLastName'
]);
$I->see('Create store');
$I->submitForm('[name ="webstore"]', [
'webstore[name]' => 'TestWebstoreName',
'webstore[description]' => 'TestWebstoreDescription',
'webstore[phone]' => '06-12345678',
'webstore[address][country]' => 'TestCountry',
'webstore[address][region]' => 'TestRegion',
'webstore[address][city]' => 'TestCity',
'webstore[address][street]' => 'TestStreet',
'webstore[address][number]' => 'TestNumber',
'webstore[address][postal]' => 'TestPostal'
]);
$I->click('//*[@id="dropdown-webshop"]/li[1]/a');
$I->see('products');
}
}
및 테스트 실행의 특정 순서에 의존
는public function tryToCreateACollection(AcceptanceTester $I)
{
$I->wantTo('I want to create a collection');
$I->click('//*[@id="mobile-demo"]/ul/a[8]');
$I->see('collections');
$I->click('//*[@id="content"]/div[2]/a');
$I->submitForm('[name="category"]', [
'category[name]' => 'TestCategory'
]);
$I->click('//*[@id="mobile-demo"]/ul/li[3]/a[1]');
$I->see('TestCategory');
$I->amGoingTo('Edit the category');
$I->click('//*[@id="content"]/div[1]/table/tbody/tr[2]/td[3]/a');
$I->fillField('category[name]', 'This is edited');
$I->attachFile('//*[@id="category_icon_picture_file"]', 'test.jpg');
$I->click('//*[@id="category_save"]');
$I->click('//*[@id="broukecrumbs"]/a[2]');
$I->see('This is edited');
$I->click('//*[@id="content"]/div[1]/table/tbody/tr[2]/td[4]/a');
}
감사 :
Codeception에서 테스트 코드를 재사용 할 수있는 올바른 방법 단계의 객체입니다 – KevinTheGreat