CLI上的PHPunit结果输出未显示测试名称 [英] PHPunit result output on the CLI not showing test names

查看:81
本文介绍了CLI上的PHPunit结果输出未显示测试名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在PHPUnit中运行一个全新的测试套件,我想查看每个测试的结果以及旁边的测试名称。

I'm running a brand new test suite in PHPUnit, I'd like to see the result of each test with the test name next to it. It would make fixing broken tests and TDD easier.

PHPunit确实会在以后输出损坏的消息,但是经过一段时间所有错误和堆栈跟踪之后,您的眼睛会变得不灵敏。

PHPunit does output the broken messages afterwards but your eyes go wonky after a while going through all the errors and stacktraces.

当前 .. F ................... 类型的输出就很棒,但是在创建套件时...

The current .......F................... type output is great once your test suite is up and stable, but while you're creating a suite...

我已经尝试过-冗长的参数,但没有帮助。

I've tried the --verbose param and it doesn't help.

推荐答案

使用 phpunit --testdox

在cli上,这将使您非常容易阅读 testdox 格式,可让您轻松查看和修复多个测试套件,例如

Use phpunit --testdox
On the cli this will give you a very readable testdox format and allow you to see and fix your multiple test suites easily e.g.

PHPUnit 3.7.37 by Sebastian Bergmann.

Configuration read from /home/badass-project/tests/phpunit.xml

AnalyticsViewers
 [x] test getViewersForMonth throws for no valid date
 [x] test getViewersForMonth limits correctly
 [x] test getViewersForMonth only returns unprocessed records
 [ ] test getViewersForMonth marks retrieved records as processed
 [ ] test getViewersForMonth returns zero for no view data
 [x] test getViewersForMonth returns valid data

Organisation
 [x] test getOrganisation returns orgs

我将它与从原始PHPUnit运行的堆栈跟踪结合使用,以快速设置。

I use it in combination with the stack traces from a vanilla PHPUnit run to quickly setup.

它还具有替换下划线的额外好处。在测试函数名称中带空格。例如, test_getViewersForMonth_returns_valid_data 变为 test getViewersForMonth对于没有视图数据返回零这更容易理解。 NB 一般来说,如果您遵循 PSR编码标准您应该使用camelCase作为方法名称,但对于单元测试方法,我违反了此规则以减少认知负荷在TDD开发过程中。

It also has the added benefit of replacing underscores in your test function names with spaces. eg test_getViewersForMonth_returns_valid_data becomes test getViewersForMonth returns zero for no view data which is more human readable.
N.B. Generally speaking if you're following the PSR coding standards you should be using camelCase for method names but for unit tests methods I break this rule to reduce cognitive load during TDD development.

这篇关于CLI上的PHPunit结果输出未显示测试名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆