13

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.

1
  • Use Jenkins! Then you will have permanent records of console output in a nice GUI.
    – nonshatter
    Jul 6, 2012 at 13:30

3 Answers 3

23

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

1
16

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.

1
  • 2
    thanks for your reply. this solved my problem. for those who are also facing similar problem following line may help.To append further test results we can use ">>" instead of ">" in the above example given by sleepynate . now it would be phpunit ArrayTest >> MyArrayTestOutput.txt.
    – sidhartha
    Aug 13, 2010 at 13:52
2

It is also possible to edit the phpunit.xml file (if you have this file available) in the root of your directory to do the logging for you.

This is especially useful for when you don't have access to a console or want to some sort of logic after all the tests. Which was the case for me. For example: Send a mail with a list of failed tests.

See the docs about this.

<phpunit ... >
    ...
    <logging>
        <junit outputFile="junit.xml"/>
        <teamcity outputFile="teamcity.txt"/>
        <testdoxHtml outputFile="testdox.html"/>
        <testdoxText outputFile="testdox.txt"/>
        <testdoxXml outputFile="testdox.xml"/>
        <text outputFile="logfile.txt"/>
    </logging>
</phpunit>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.