2015-11-04 57 views
0

第一次嘗試:--- 當我運行貝哈特與功能設置錯誤而在laravel運行貝哈特5

Feature: Authentication 
Checking Application Authentication Functionality. 

@javascript 
Scenario: Admin Redirect Page 
    Given I am on "/admin/dashboard" 
    Then I should be on "/admin/login" 

Scenario: Admin Login Failure 
    When I go to "/admin/login" 
    And I fill in "email" with "[email protected]" 
    And I fill in "password" with "wrongpassword" 
    And I press "Login" 
    Then I should see "Login Failure" 

第一種方案的工作,但第二個失敗,響應: -

Scenario: Admin Redirect Page  # app/tests/behat/features/auth.feature:5 
    Given I am on "/admin/dashboard" # FeatureContext::visit() 
    Then I should be on "/admin/login" # FeatureContext::assertPageAddress() 

    Scenario: Admin Login Failure         # app/tests/behat/features/auth.feature:9 
    When I go to "/admin/login"        # FeatureContext::visit() 
     Target [Illuminate\Contracts\Http\Kernel] is not instantiable. (Illuminate\Contracts\Container\BindingResolutionException) 

第二次嘗試:--- 我試着刪除第一個場景來測試我的功能是否損壞,併成功運行。

Scenario: Admin Login Failure         # app/tests/behat/features/auth.feature:9 
    When I go to "/admin/login"         # FeatureContext::visit() 
    And I fill in "email" with "[email protected]" # FeatureContext::fillField() 
    And I fill in "password" with "wrongpassword"    # FeatureContext::fillField() 
    And I press "Login"           # FeatureContext::pressButton() 
    Then I should see "Login Failure"       # FeatureContext::assertPageContainsText() 

1 scenario (1 passed) 
5 steps (5 passed) 
0m3.70s (23.80Mb) 

我不知道爲什麼它在我實現2場景時失敗。

第三嘗試:---

Feature: Authentication 
    Checking Application Authentication Functionality. 

    @javascript 
    Scenario: Admin Redirect Page 
     Given I am on "/admin/dashboard" 
     Then I should be on "/admin/login" 

    Scenario: Admin Redirect Page 
     Given I am on "/admin/dashboard" 
     Then I should be on "/admin/login" 

    Scenario: Admin Redirect Page 
     Given I am on "/admin/dashboard" 
     Then I should be on "/admin/login" 

結果: -

Feature: Authentication 
    Checking Application Authentication Functionality. 

    @javascript 
    Scenario: Admin Redirect Page  # app/tests/behat/features/auth.feature:5 
    Given I am on "/admin/dashboard" # FeatureContext::visit() 
    Then I should be on "/admin/login" # FeatureContext::assertPageAddress() 

    Scenario: Admin Redirect Page  # app/tests/behat/features/auth.feature:9 
    Given I am on "/admin/dashboard" # FeatureContext::visit() 
     Target [Illuminate\Contracts\Http\Kernel] is not instantiable. (Illuminate\Contracts\Container\BindingResolutionException) 
    Then I should be on "/admin/login" # FeatureContext::assertPageAddress() 

    Scenario: Admin Redirect Page  # app/tests/behat/features/auth.feature:13 
    Given I am on "/admin/dashboard" # FeatureContext::visit() 
     Target [Illuminate\Contracts\Http\Kernel] is not instantiable. (Illuminate\Contracts\Container\BindingResolutionException) 
    Then I should be on "/admin/login" # FeatureContext::assertPageAddress() 

--- Failed scenarios: 

    app/tests/behat/features/auth.feature:9 
    app/tests/behat/features/auth.feature:13 

3 scenarios (1 passed, 2 failed) 
6 steps (2 passed, 2 failed, 2 skipped) 
0m2.87s (24.19Mb) 
+0

我laravel 5.1.23 而貝哈特所需的軟件包 「貝哈特/小黃瓜」: 「^ 4.3」, 「貝哈特/貂皮selenium2驅動器」: 「^ 1.2」, 「貝哈特/貂皮browserkit-驅動程序「:」^ 1.2「, 」laracasts/integrated「:」^ 0.15.6「, 」behat/behat「:」^ 3.0「, 」behat/mink「:」^ 1.6「, 」behat /水貂擴展「:」^ 2.0「, 」laracasts/behat-laravel-extension「:」^ 1.0「, –

+0

我正在學習使用laracast學習。您的第二個方案中的 –

+0

是否有意去google.com? – Leo

回答

0

就想通了,你需要添加這些2所有場景。如果任何人有同樣的問題,這可能是任何幫助。

@javascript @mink:selenium_session 

默認我的配置是通過behat.yml CMD上線運行了這個

sessions: 
     default_session: 
      laravel: ~ 
     goutte_session: 
      goutte: ~ 
     selenium_session: 
      selenium2: 
      wd_host: http://127.0.0.1:4444/wd/hub 

因此增加@javascript上的瀏覽器,並通過指定貂會話使用硒運行測試,您可以訪問您的應用的所有JavaScript功能。

+0

另請注意,錯誤是因爲第二種情況在命令行上運行 –