2016-06-30 2 views
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'); 

} 

答えて

0

は、テスト香りです。

Codeceptionにテストコードを再利用するための正しい方法は、ステップオブジェクトである:私は基本的に、特定の順序でそれらを実行する方法を見つけるためにしようとしていたため、それは、私が探していたものであるhttp://codeception.com/docs/06-ReusingTestCode#StepObjects

+0

感謝 – KevinTheGreat

関連する問題