Search code examples
phptddphpunitpear

command not found error while running php test code in command prompt


I followed the site http://elentok.blogspot.com/2011/10/install-phpunit-on-wampserver.html for installing PHPUnit framework for unit testing in PHP. I have downloaded both pear and PHPUnit. I have installed both of them by following the steps described in above website. That worked also. but at last, i tried to run the php program:::

class MyTest extends PHPUnit_Framework_TestCase
{
    public function testOneEqualsOne()
    {
      $this->assertEquals(1, 1);
    }
}

-> I typed the command phpunit Mytest.php in command prompt, but doesn't run. And showed the error phpunit is not recognized as internal or external command,operable program or batch file. I have tried it on c:\wampp\www\myproject> . How to run this code and use PHPUnit testing framework properly? Is there anything wrong in installation? I have installed PHPUnit on wampp server. If I am wrong, please help me for installing PHPUnit and using it properly. My system is Windows 07 64-bit, and I am using wampp server.


Solution

  • you have to include the Autoload.php file in you php test file:

    require_once 'path/to/PHPUnit/Autoload.php';