samedi 31 octobre 2015

Write unit test for console application with arguments

currently i write a little program foobar.php, which is a console application. The program get a path to a file, read the content, do some magic and writes a result on "stdout".

Now i will write a test for this program and i'm not sure how to write such a test.

I found one solution (How to launch properly php cli script in phpunit test?).

Based on this url i can wirte a test with one method. In this method a call the program this proc_open(), catch the response from stdout and check it with $this->assertEquals() but I dont know if that's the right way.

Aucun commentaire:

Enregistrer un commentaire