punktde/codeception-maildev

提供模块和Gherkin步骤,用于访问maildev API进行codeception测试

2.0.1 2023-02-02 13:47 UTC

This package is auto-updated.

Last update: 2024-09-07 12:20:08 UTC


README

使用MailDev进行测试的Gherkin步骤和模块函数

如何使用

先决条件

您必须安装MailDev,并将您的应用程序配置为向maildev发送邮件。请参阅https://github.com/maildev/maildev

模块

您必须将Webdriver模块添加到您的配置中才能使用MailDev模块。在您的codeception.yaml中使用模块PunktDe\Codeception\MailDev\Module\MailDev。您可以在配置中指定maildev客户端可访问的uri(默认为http://127.0.0.1:8025

modules:
   enabled:
      - WebDriver:
        url: 'http://acceptance.dev.punkt.de/'
        browser: chrome
        restart: true
        window_size: 1920x2080
        capabilities:
          chromeOptions:
            args:
              - '--headless'
              - '--disable-gpu'
              - '--disable-dev-shm-usage'
              - '--no-sandbox'
      - PunktDe\Codeception\MailDev\Module\MailDev:
        base_uri: http://maildev.project

您可以在必要时向guzzle客户端添加身份验证参数进行身份验证。有关更多详细信息,请参阅https://docs.guzzlephp.org/en/latest/request-options.html#auth

modules:
   enabled:
      - PunktDe\Codeception\MailDev\Module\MailDev:
        base_uri: http://maildev.project
        username: 'user'
        password: 'secret'
        atheticationType: 'basic'

Gherkin步骤

只需将特质PunktDe\Codeception\MailDev\ActorTraits\MailDev添加到您的测试演员中。然后您可以使用新的步骤编写带有*.feature文件的gherkin测试。

示例演员
<?php

/*
 *  (c) 2018 punkt.de GmbH - Karlsruhe, Germany - http://punkt.de
 *  All rights reserved.
 */

/**
 * Inherited Methods
 * @method void wantToTest($text)
 * @method void wantTo($text)
 * @method void execute($callable)
 * @method void expectTo($prediction)
 * @method void expect($prediction)
 * @method void amGoingTo($argumentation)
 * @method void am($role)
 * @method void lookForwardTo($achieveValue)
 * @method void comment($description)
 * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
 *
 * @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
    use _generated\AcceptanceTesterActions;
    use \PunktDe\Codeception\MailDev\ActorTraits\MailDev; // use the maildev steps trait
}
有哪些步骤?

要获取所有可用的步骤,您只需运行以下命令

vendor/bin/codecept -c path/to/codeception.yaml gherkin:steps suiteName

这将提供一个所有可用步骤的表格。