简体   繁体   English

Laravel 5 phpunit没有运行测试

[英]Laravel 5 phpunit is not running tests

I'm been at this for days with no success. 我已经在这几天没有成功了。 Running Laravel 5.1 . 运行Laravel 5.1 As I understand according to the Laravel doc. 据我了解,根据Laravel文件。

An ExampleTest.php file is provided in the tests directory. tests目录中提供了一个ExampleTest.php文件。 After installing a new Laravel application, simply run phpunit on the command line to run your tests. 安装新的Laravel应用程序后,只需在命令行上运行phpunit即可运行测试。

Ok so after running phpunit I found it is not globally installed and is located in vendor/bin/phpunit . 好吧,运行phpunit我发现它没有全局安装,位于vendor/bin/phpunit Proceeding to run vendor/bin/phpunit gives me a screen with all the command options for phpunit. 继续运行vendor/bin/phpunit为我提供了一个屏幕,其中包含phpunit的所有命令选项。 Its does not actually run any tests. 它实际上没有进行任何测试。

I searched more and came across a post that mentioned it could be a symlink issue. 我搜索了更多,并发现一个帖子 ,提到它可能是一个symlink问题。 I followed the instructions in the post with no success. 我按照帖子中的说明没有成功。 From memory I installed Laravel from composer so the symlink should not be an issue anyway. 从内存中我从作曲家安装了Laravel ,所以symlink不应该是一个问题。

These instructions involved deleting various files. 这些说明涉及删除各种文件。 I did notice that composer was pulling files from its cache when updating. 我注意到作曲家在更新时从其缓存中提取文件。 So I cleared its cache and followed the process again. 所以我清除了它的缓存并再次遵循该过程。 Still no success. 仍然没有成功。

What are the tests not running? 什么是没有运行的测试? I'm at my wits end. 我的智慧结束了。 Especially since its is supposed to run easily out the box. 特别是因为它应该可以轻松地运行。

In the end I was not calling the bat file correctly. 最后我没有正确调用bat文件。 I was running 我之前在跑步

C:\\localhost\\myProject\\vendor\\bin> phpunit

Instead I needed to run 相反,我需要运行

C:\\localhost\\myproject> call vendor\\bin\\phpunit

Hence it now is referencing the phpunit.xml file with the test location information. 因此,它现在引用带有测试位置信息的phpunit.xml文件。

You need to install phpunit globally: composer global require phpunit/phpunit 你需要全局安装phpunit: composer global require phpunit/phpunit

Then you can run phpunit from your project root. 然后你可以从你的项目根运行phpunit

You could just run the phpunit that comes with the project, just go to your project root and run ./vendor/bin/phpunit , that way the tests will execute the way they should be and you could get feedback in case it fails. 您可以运行项目附带的phpunit,只需转到您的项目根目录并运行./vendor/bin/phpunit ,这样测试将按照应有的方式执行,如果失败,您可以获得反馈。

For some reason I haven't figure out yet if you install phpunit globally in your computer you won't get feedback of your tests. 出于某种原因,我还没弄清楚如果你在你的计算机上全局安装phpunit,你将无法获得测试的反馈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM