yawik / behat

此包为yawik提供Behat测试工具

1.0.5 2020-12-20 14:29 UTC

README

Yawik使用behat进行浏览器测试。以下是运行behat测试的步骤

警告!!!

为了执行安装测试,behat将创建config/autoload/install.module.php文件。如果您始终通过安装页面进入yawik安装,请手动删除此文件并恢复备份文件

$ cd path/to/yawik
$ rm config/autoload/install.module.php
$ mv config/autoload/yawik.backup config/autoload/yawik.config.global.php

Behat配置

复制默认behat配置文件

$ cp behat.yml.dist behat.yml

behat.yml配置文件中编辑base_url以匹配您本地的yawik安装URL

# change base url to match your location
default:
    ...
    extensions:
        ...
        Behat\MinkExtension:
            # change this base url value to match
            # your local development server url:
            base_url: "https://:8000"
            files_path: "%paths.base%/module/Behat/resources/fixtures/"

运行Behat测试

使用chrome驱动启动selenium独立服务器

$ cd path/to/yawik
$ ./bin/start-selenium.sh

您可以使用此命令运行所有场景

$ cd path/to/yawik
$ ./vendor/bin/behat

仅运行特定功能的behat

$ ./vendor/bin/behat features/install.feature

仅运行特定场景的behat

$ ./vendor/bin/behat features/install.feature:12

上面的命令将只运行features/install.feature文件第12行的场景

截图

由于默认情况下behat将在无头模式下执行测试,您可以在build/behat目录中查看behat失败的测试截图。*.png文件将显示浏览器截图,而*.log文件将显示测试期间的实际HTML输出。

邮件和社会资料功能

默认情况下,behat将跳过邮件和社会资料测试,因为这会导致travis错误。要执行这些跳过的测试,您需要确保您的邮件和社会登录配置有效,并在测试期间配置要使用的社交资料用户

# path/to/yawik/behat.yml
default:
    suites:
        user:
            contexts:
                - Yawik\Behat\UserContext:
                      parameters:
                          social_login_info:
                              facebook:
                                  email:  <test-facebook-user>
                                  pass:   <test-facebook-password>
                              linkedin:
                                  session_key-login:      <test-linked-in-user>
                                  session_password-login: <test-linked-in-password>

您可以使用此命令运行这些跳过的测试

# to run mail tests:
$ cd path/to/yawik
$ ./vendor/bin/behat --tags=@mail

# to run social profile tests
$ cd path/to/yawik
$ ./vendor/bin/behat --tags=@social-profile