Codeception:从其他验收测试调用方法

Codeception:从其他验收测试调用方法,codeception,Codeception,我有多个验收测试,需要按特定顺序运行。因为他们彼此依赖。现在,我如何在createstore类中调用tryToCreateACollection,以便可以从那里运行它,以便按照我想要的顺序运行 class CreateStoreCest { public function _before(AcceptanceTester $I) { $I->amOnPage('http://127.0.0.1:8000/login'); $I->submitForm('[name="lo

我有多个验收测试,需要按特定顺序运行。因为他们彼此依赖。现在,我如何在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');

}
}


依赖于测试执行的特定顺序是一种测试气味


在Codeception中重用测试代码的正确方法是步骤对象:

依赖于特定的测试执行顺序是一种测试气味


在Codeception中重用测试代码的正确方法是Step objects:

谢谢这是我一直在寻找的,因为我基本上是在试图找到一种按特定顺序执行它们的方法谢谢这是我一直在寻找的,因为我基本上是在试图找到一种按特定顺序执行它们的方法
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');

}