gpt4 book ai didi

php - 无法使用 PhpStorm 运行代码覆盖

转载 作者:行者123 更新时间:2023-12-05 06:44:42 27 4
gpt4 key购买 nike

我正在尝试使用代码覆盖率在 PhpStorm 中运行单元测试。它向我抛出一条错误消息,说缺少解释器。如何安装解释器!

还有如何配置以运行具有代码覆盖率的测试。

Edit Configuration

最佳答案

执行步骤:

1。设置口译员和语言级别。

文件 -> 设置 -> 语言和框架 -> PHP

选择您的 PHP 版本。然后单击带有 ... 的按钮(三个点),然后添加解释器。

https://www.jetbrains.com/phpstorm/help/interpreters.html

2。将 PHPUnit 添加到项目中。

文件 -> 设置 -> 语言和框架 -> PHPUnit

a) 加载表单包含路径

要添加它,您必须设置 PHPUnit 库的安装位置。然后在 Project 中使用 External Libraries 添加。

adding include paths

要指定路径,请使用绿色的 + 按钮。

b) 使用自定义自动加载器

通过 composer 安装 PHPUnit 时使用此选项。在 Path to script 字段中指定自动加载文件。

https://www.jetbrains.com/phpstorm/help/phpunit.html

3。配置测试

在右上角使用Select Run/Debug Configuration菜单

run debug configration

然后单击编辑配置。选择绿色的 + 按钮添加 PHPUnit。

add phpunit

用测试定义配置和目录的名称。此外,您可以在 Test Runner options 字段中添加一些 PHPUnit 参数。

https://www.jetbrains.com/phpstorm/help/run-debug-configuration-phpunit.html

注解1——配置bootstrap

测试有时需要使用引导文件来设置环境、加载配置等。要设置此文件,请转到:

文件 -> 设置 -> 语言和框架 -> PHPUnit

并在Default bootstrap file字段中选择bootstrap文件。

bootstrap file

https://www.jetbrains.com/phpstorm/help/phpunit.html - 在 Bootstrap 文件 部分。

注解2 - 以代码覆盖率运行测试

要覆盖运行,您必须安装 Xdebug PHP 扩展。 You should read the Xdebug installation guide .

此操作后使用图标

coverage

在覆盖范围内运行。

https://www.jetbrains.com/phpstorm/help/code-coverage.html

关于php - 无法使用 PhpStorm 运行代码覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28104652/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com