Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we save the result of PHPUnit test

Tags:

phpunit

Is it possible to save the result generated from a PHPUnit test as a text file or as a html file so that we can review it later and send it to concerned person through email? Simply my requirement is to save the out put,that we get in an IDE (Netbean or Eclipse) or in the command prompt into a file in the local system(the system where i perform the test) . after searching a long i did not find a required solution. if anybody has a solution please help me.

like image 665
sidhartha Avatar asked Aug 11 '10 14:08

sidhartha


People also ask

What is PHPUnit XML file?

PHPUnit uses XML file for configuration. This configuration file can be added to your version control system so all developers get the same output. These settings will help you make sure your tests work the way you want.

What is the use of PHPUnit?

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 assertion in PHPUnit?

PHPUnit assertTrue() Function The assertTrue() function is a builtin function in PHPUnit and is used to assert whether the assert value is true or not. This assertion will return true in the case if the assert value is true else returns false.

What is mock PHPUnit?

Likewise, PHPUnit mock object is a simulated object that performs the behavior of a part of the application that is required in the unit test. The developers control the mock object by defining the pre-computed results on the actions.


2 Answers

PHPUnit offers three command-line options for saving results to a file also:

phpunit --log-junit results.xml test.php - saves results of test.php as XML file results.xml

phpunit --log-tap - will save as TAP

phpunit --log-json - will save as JSON

like image 153
ivete Avatar answered Sep 21 '22 21:09

ivete


if you're using the command prompt on unix, couldn't you just use the > to redirect the output to a text file?

phpunit ArrayTest > MyArrayTestOutput.txt

Most IDEs will also let you copy/paste the output of their buffer/terminal to wherever your heart desires.

like image 28
sleepynate Avatar answered Sep 18 '22 21:09

sleepynate