phpunit入门

栏目: PHP · 发布时间: 6年前

安装

安装教程参考

说明

  • windows下安装那个盘符无所谓
  • windows下如果不定义全局变量,可以进入phpunit.phar所在目录才能执行,例如:

    cd G:/phpstudy/phptutorial/tool/phpunit
    phpunit --version
    #当然配环境变量,全局配置操作更方便一点
  • 全局配置,配置环境变量的路径是“建立外包覆批处理脚本(最后得到 C:binphpunit.cmd):”官方教程里面第五步的所在路径

配置

  • 配置composer 参考

    • 例如
    {
        "autoload": {
            "classmap": [
                "src/"
            ]
        },
        #核心
        "require-dev": {
            "phpunit/phpunit": "^8"
        }
    }
  • 安装依赖
composer install

使用

  • 常用操作
phpunit --bootstrap vendor/autoload.php tests/EmailTest //测试自己写的Email类
phpunit --bootstrap vendor/autoload.php --testdox tests //testDox查看测试结果
  • 常用断言函数
assertTrue
assertFalse
assertInstanceOf
assertSame
assertEquals
assertEmpty
assertArrayNotHasKey

示例代码

zeron do php


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Eric Meyer on CSS

Eric Meyer on CSS

Eric Meyer / New Riders Press / 2002-7-8 / USD 55.00

There are several other books on the market that serve as in-depth technical guides or reference books for CSS. None, however, take a more hands-on approach and use practical examples to teach readers......一起来看看 《Eric Meyer on CSS》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试