1

次のシナリオがあります。

@wip
Scenario: Attempt to get account information of an activator without credentials
Given an activator with e-mail "dietervds@email.com" and password "testpassword" already exists
When I send a GET request to "/activators/1"
Then the response code should be 401

@wip
Scenario: Attempt to get account information of another activator then myself
Given an activator with e-mail "dietervds@email.com" and password "testpassword" already exists
And an activator with e-mail "eviltwin@email.com" and password "testpassword" already exists
And I am authenticating as "eviltwin@email.com" with "testpassword" password
When I send a GET request to "/activators/1"
Then the response code should be 401

すべてのシナリオの前に、データベースが削除され、スキーマから再作成されます。

'given an activator with ...' のステップは、新しいユーザーをデータベースに挿入します。
でも!両方のユーザーに対して常にそうするとは限りません。

これはステップの実装です:

/**
 * @Given /^an activator with e-mail "([^"]*)" and password "([^"]*)" already exists$/
 */
public function anActivatorWithEMailAndPasswordAlreadyExists($email, $password)
{
    $activatorManager = $this->getContainer()->get('am.manager.activator');
    #$logger = $this->getContainer()->get('logger');
    #$logger->debug("Email: $email, password: $password");
    $activator = $activatorManager->createActivator($email, $password);
    $activatorManager->save($activator);
}

ここで奇妙なこと
に、最後のステップで、2 つのインサートを取得する必要があります。

次の場合に2つの挿入を取得します。

  • シナリオを 1 つだけ実行する
  • ログに何かを出力します (「ロガー」を作成しても役に立ちません。何かを出力する必要があります。出力するものは動的である必要はなく、固定文字列にすることができます)

次の場合、(dietervds 用に) 1 つの挿入のみを取得します。

  • 2 つのシナリオを一緒に実行する
  • または、ステップの実装でログを出力しない場合

私はこれに完全に困惑しています。
明らかに欠けているものはありますか?ステップ定義で何らかのキャッシングの問題が発生している可能性がありますか? (ロギングにより署名または何かが変更される可能性がありますが、わかりません)

フィードバックは大歓迎です:-)

乾杯!

ディーター

4

1 に答える 1

1

このステップは ajax 呼び出しを行いますか?

「/activators/1」にGETリクエストを送ると

その場合は、そこに待機時間を追加して、dom に結果をロードする時間を与えることができます

Whens to Thens は、プレスまたはリンクをたどるフォームを送信する場合、または go to を実行してブラウザーをリダイレクトする場合に最適に機能します。これにより、ロボットが新しい DOM のロードを待機するようトリガーする完全な要求応答サイクルが開始されます。

まったく同じようには起こらない ajax の場合。

ajax を行っていない場合は、組み込みのステップ定義を使用することをお勧めします。

When I follow "/activators/1" instead

yaml 構成でキャッシュを防止する方法があります。これはクロムに使用する構成の例ですが、どのブラウザードライバーでも同じように機能するはずです

default:
    extensions:
        Behat\MinkExtension\Extension:
            base_url: https://yurwebsite.com
            goutte: ~            
            browser_name: "googlechrome"
            selenium2:
                capabilities: { "browser": "googlechrome", "version": "23", "applicationCacheEnabled": false }

最後のブール値パラメーターは、ブラウザーのキャッシュの問題を解決します

于 2013-01-08T03:08:20.540 に答える