如何从PHP Artisan测试中捕获文件中的输出?

发布于 2025-01-26 17:44:17 字数 360 浏览 3 评论 0原文

当我运行PHP Artisan Test时,我想保存所有输出测试生成的生成在文件中。我尝试做PHP Artisan测试2> te.txt 1> to.txt。但是文件是空的。我在做什么错?

我还尝试了PHP手工测试| Tee Test.txtphp工匠测试> test.txt。他们俩都不起作用。

https://youtu.be/pqnfmdqwixs

When I run php artisan test, I want to save all the output test generates in a file. I tried doing php artisan test 2> te.txt 1> to.txt. But the files are empty. What am I doing wrong?

I also tried php artisan test | tee test.txt or php artisan test > test.txt. Both of them doesn't work.

https://youtu.be/pqNfMDqwixs

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

俏︾媚 2025-02-02 17:44:17

为了使其正常工作,

您需要无关的选项:

php artisan test --without-tty > test.txt

但是请注意,它将填充有颜色代码,例如:

[31;1m⨯[39;22m[39m [2m myTest [22m[39m

为了正确显示它,您需要猫文件。

For it to work,

you need the without-tty option :

php artisan test --without-tty > test.txt

but be aware that it will be filled with color codes, like :

[31;1m⨯[39;22m[39m [2m myTest [22m[39m

so to display it correctly you will need to cat the file

糖粟与秋泊 2025-02-02 17:44:17

您可以使用此语法用控制台输出填充文件

php artisan test >> test.txt

you can use this syntax to fill the file with console output

php artisan test >> test.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文