Laravel 项目运行 phpunit 测试结果只显示点号

在laravel 项目的根目录下,运行 phpunit 只显示 点号的情况

我尝试将 tests/Unittests/Feature 目录将 ExampleTest.php 文件删除,然后再运行phpunit,就不只显示点号了


其中尝试了另外安装phpunit,降低 Laravel 安装的版本,重新安装一个vagrant LNMP环境,同一个项目运行 phpunit 都是只显示点号

看到 Homestead中运行 phpunit是运行 vendor/bin/phpunit的文件

在 Homestead 虚拟机内中按照官网 phpunit 的开始文档 开始说明安装 phpunit 6

wget -O phpunit https://phar.phpunit.de/phpunit-6.phar
chmod +x phpunit
./phpunit --version
sudo mv phpunit /usr/local/bin/phpunit6 
phpunit6 --version #查看phpunit的版本,测试是否安装成功
Reference
  1. 使用 TDD 测试驱动开发来构建 Laravel REST API 看到这篇文章,学习到需要删除 laravel项目测试文件夹(tests)下的 ExampleTest.php,使我们的测试结果不被影响

  2. PHPunit result output on the CLI not showing test names 知道 phpunit 命令有一个 --testdox 参数,会列出当前所有单元测试列表,类似于 TODOList,成功前面有 [ X ],测试失败是空的 [ ]

  3. phpunit --debug still displays only dots

  4. 简单的11步在Laravel中实现测试驱动开发 学习到,在测试基类中,可以添加 Faker 这个变量,在基类中,也可以mock数据,就不会固定死数据了

原文地址:https://www.cnblogs.com/fsong/p/11336976.html