- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的功能测试文件
<?php
namespace api\tests;
use api\tests\FunctionalTester;
use Yii;
class ExampleCest
{
public function _before(FunctionalTester $I)
{
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->sendGET('example/test2');
$I->seeResponseCodeIs(200); // Unauthorized
$I->seeResponseContains('test2');
}
}
我尝试了 2 个不同的 functional.suite.yml 文件来运行测试:
// 1. functional.suite.yml, test run successfully:
actor: FunctionalTester
modules:
enabled:
- REST:
url: http://api.xxxxx.local/v1/
depends: PhpBrowser
part: Json
- \api\tests\Helper\Functional
// 2. functional.suite.yml, test failed without setting defaultRoute in Yii configuration file, but succeed if I set `'defaultRoute' => 'v1/example/test2',`:
actor: FunctionalTester
modules:
enabled:
- REST:
url: v1/
depends: Yii2
part: Json
- \api\tests\Helper\Functional
失败时的错误信息:
ExampleCest: Try to test Signature: api\tests\ExampleCest:tryToTest Test: tests/functional/ExampleCest.php:tryToTest Scenario -- I send get "example/test2" [Request] GET v1/example/test2 [Request Headers] [] [yii\web\HttpException:404] 'yii\base\InvalidRouteException: Unable to resolve the request "". in /Applications/MAMP/htdocs/gaea/vendor/yiisoft/yii2/base/Module.php:537
我不知道为什么第二个 functional.suite.yml 文件失败了,因为我可以在浏览器中从 http://localhost/MYPROJECT/api/web/index.php?r=v1/example/test2 得到正确的响应。 .
我的环境:
Codeception: v2.3.8
Yii: v2.0.14
PHP: v7.0.26
最佳答案
我通过将 url: v1/
更改为 url:/v1
或删除它来解决这个问题。
关于php - 在 Yii2 中使用 codeception 进行功能测试时出现 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49854215/
我的表单包含一个隐藏字段 csrf 并且我的 Controller 有一个方法来检查 CSRF 攻击。在我的功能测试中,我尝试通过fillField 来检查我的Controller 的方法 如果有人t
我正在 docker 容器中进行 Codeception 验收测试。我可以运行整个项目,但不能运行单个测试或类。是否有任何配置选项或参数来解决这个问题? 这有效(运行所有测试): codecept -
我正在使用 Codeception 运行验收测试,我需要计算带有“.remove”类的按钮在一页中出现的次数。此类按钮位于 html 表内,计数取决于购物车中的商品数量。 下面是我尝试使用的代码:
就像我们在 codecetion 中从命令提示符传递浏览器名称和其他详细信息一样,我们可以从命令提示符传递可以在脚本中使用的任何变量吗? 最佳答案 我没有在文档和其他提要中找到任何方法。 我为此能力添
在 PHP Codeception test framework ,我希望能够一次运行多个套件。 我可以像这样运行它们: codecept run 或者我可以像这样运行单个套件: codecept r
我正在使用 codeception,当我尝试检查 dbconnection 时它显示错误: > DEPRECATION: Calling the > "Symfony\Component\EventD
$I->fillField("username", "test"); 在运行验收测试时,收到以下错误: 抱歉,我无法填写字段“用户名”、“测试”: ErrorException: DOMXPath::
我有 API 端点: [GET] /car/:carId 这实际上是一个 Controller Action (CarController::car( $carId ) ): public funct
我有一个 PHP 应用程序,我们正在使用 Codeception 添加测试。我们尝试将 Specify(和 Verify)添加到我们的套件中,但未被识别。您如何正确设置 Specify 以与 Code
我正在尝试为使用 Codeception 的 Paypal Express Checkout 付款编写验收测试。问题是上下文窗口。当我没有窗口名称时,如何切换到那个窗口来填写字段?感谢您的帮助。 最佳
我正在编写一个测试,但它没有像我预期的那样工作。 我需要使用一些抓取器,然后在测试运行时转储到屏幕上。 我该怎么做?如何回显,而不是用户抓取器如何;我可以使用抓取器,但我不知道如何在测试运行时回显。
-- Select an Option -- @foreach ($options as $option) value }}'>{{ $option->name }}
刚开始使用 codeception 2.0.9 并安装了 phantomjs 并运行了一些示例测试。 Codeception 在最后给出了一个简洁的 html 报告,用红色和绿色总结了通过的测试,这很
我正在使用 Codeception 运行验收测试,我需要计算带有“.remove”类的按钮在一页中出现了多少次。此类按钮位于 html 表格内,计数取决于购物车中的商品数量。 以下是我尝试使用的代码:
使用 Codeception 测试框架和 Selenium 2 模块来测试一个网站,我最终点击了一个超链接,该超链接打开了一个没有名称的新窗口。结果, switchToWindow() 函数将无法工作
亲爱的 Stackoverflow 用户,您好 目前我正在使用 Selenium 作为 WebDriver 模块使用 Codeception 编写验收测试。在我检查我们的子导航是否存在、是否完整并且有
我在 Yii2 中使用 Codeception 进行验收测试,但无法访问我的模型,因为命名空间不适用于这些测试。 我在我的测试/_bootstrap.php 中有这个 require(__DIR__
我一直在使用 Codeception 编写一些单元测试,并且我的数据库已被测试数据过度运行。在阅读文档时,我发现它说: Database will be cleaned and populated a
有没有办法断言某个元素(例如输入或链接)具有键盘焦点?我正在将 Codeception 与 Selenium 结合使用。在 http://codeception.com/docs/modules/We
我无法通过代码接收复制 ajax 调用。 例如: $I->sendAjaxPostRequest('login/verify', array('name' => 'name', 'password'
我是一名优秀的程序员,十分优秀!