04/12/2016 - BEHAT
Eğer bir veya birden fazla behat senaryosunun diğerlerine göre farklı işler yapmasını isterseniz tagged hooks kullanabilirsiniz.
Her ne kadar aşağıdaki senaryoların hepsi aynı şeyi yapsalarda, en sondaki senaryo @do-something-special
ile etiklenmiş olduğu için farklı bir şey yapacak.
Feature: Listing countries
In order to list countries
As a user
I should be able to navigate to country page
Scenario: Listing all countries
Given I am on "/country"
Then I should see "Turkey"
Scenario: Listing all countries
Given I am on "/country"
Then I should see "Germany"
@do-something-special
Scenario: Listing all countries
Given I am on "/country"
Then I should see "United Kingdom"
namespace AppBundle\Features\Context;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Symfony2Extension\Context\KernelAwareContext;
use Symfony\Component\HttpKernel\KernelInterface;
class FeatureContext extends MinkContext implements KernelAwareContext
{
/** @var KernelInterface */
private $kernel;
public function setKernel(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
/**
* @BeforeScenario @do-something-special
*/
public function doSomethingSpecial()
{
echo 'I did something special...';
}
}
Feature: Listing countries
In order to list countries
As a user
I should be able to navigate to country page
Scenario: Listing all countries # src/AppBundle/Features/Country.feature:6
Given I am on "/country" # AppBundle\Features\Context\FeatureContext::visit()
Then I should see "Turkey" # AppBundle\Features\Context\FeatureContext::assertPageContainsText()
Scenario: Listing all countries # src/AppBundle/Features/Country.feature:10
Given I am on "/country" # AppBundle\Features\Context\FeatureContext::visit()
Then I should see "Germany" # AppBundle\Features\Context\FeatureContext::assertPageContainsText()
┌─ @BeforeScenario @do-something-special # AppBundle\Features\Context\FeatureContext::doSomethingSpecial()
│
│ I did something special...
│
@do-something-special
Scenario: Listing all countries # src/AppBundle/Features/Country.feature:15
Given I am on "/country" # AppBundle\Features\Context\FeatureContext::visit()
Then I should see "United Kingdom" # AppBundle\Features\Context\FeatureContext::assertPageContainsText()
3 scenarios (3 passed)
6 steps (6 passed)
0m0.68s (31.55Mb)