Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does phpunit not show any errors in the console

I'm using phpunit with Laravel 4 framework. Why is it that when there's a PHP error during the tests, no error messages are shown (eg: missing method)?

How can we get phpunit to show all errors?

enter image description here

like image 834
Nyxynyx Avatar asked Aug 04 '13 21:08

Nyxynyx


People also ask

What is a PHPUnit test?

PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit design for unit testing systems that began with SUnit and became popular with JUnit. Even a small software development project usually takes hours of hard work.

What is the use of PHPUnit?

PHPUnit is a framework independent library for unit testing PHP. Unit testing is a method by which small units of code are tested against expected results. Traditional testing tests an app as a whole meaning that individual components rarely get tested alone.

What is PHPUnit XML file?

PHPUnit can optionally backup all global and super-global variables before each test and restore this backup after each test. This attribute configures this operation for all tests. This configuration can be overridden using the @backupGlobals annotation on the test case class and test method level.

What is PHPUnit laravel?

Use Laravel Unit Testing to Avoid Project-Wrecking Mistakes. Pardeep Kumar. 7 Min Read. PHPUnit is one of the most well known and highly optimized unit testing packages of PHP. It is a top choice of many developers for rectifying different developmental loopholes of the application.


1 Answers

This is a very common issue, especially when you are running tests on a production server or when the tester isn't very aware of the PHP configuration.

The issue is related to php.ini settings, as pointed by Alexander Yancharuk in his answer and all the solutions he suggests work fine.

But there is another solution that may be useful, as it was for me, which is to set the appropriate PHP settings in the PHPUnit configuration file (XML) itself, as follows:

<phpunit>     <suites>         ...     </suites>     <php>         <ini name="display_errors" value="On" />         <ini name="display_startup_errors" value="On" />     </php> </phpunit> 

Using this you can personalize not only error display, but a lot of PHP configuration, specifically for your test suite, leaving your production configuration untouched and without having to write a bootstrap file only for this.

like image 140
Victor Schröder Avatar answered Oct 12 '22 01:10

Victor Schröder