[英]Error while running behat on laravel 5
第一次尝试:---当我运行behat并将功能设置为
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 "testaccount@gmail.com"
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)
第二次尝试:---我尝试删除第一种情况,以测试我的功能是否已损坏并且behat成功运行。
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 "testaccount@gmail.com" # 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)
刚弄清楚,您需要为所有场景添加这两个。 如果有人遇到同样的问题,这可能会有所帮助。
@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可以在浏览器上进行测试,并通过指定Mink会话以使用硒可以使您访问应用程序的所有javascript功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.