Page 1 of 1

phpunit testing framework and phpunitwebui

Posted: Thu Jul 21, 2011 10:54 pm
by iansane
Hi, I found phpunitwebui here http://sourceforge.net/projects/phpunitwebui/ and I'm trying to get it setup to use because I don't understand how to use phpunit by it's self when I don't get any type of visual confirmation that the test ran. Maybe I'm missing how to use phpunit.

Either way, I have some questions about the config.php file in phpunitwebui.

Code: Select all

<?php
/**
 * PHPUnit Test Runner WUI Sample config file.
 */

// the root directory of the tests
define('ROOT_DIR', '../testunits');

// excluded folders patterns
$exclude = array('/PHPUnit/');

// test file suffix (used to determine test files from other files)
define('TEST_SUFFIX', 'Test');

// the directory where the code coverage reports will be generated
define('CODE_COVERAGE_DIR', dirname(__FILE__) . '/CodeCoverageReports');

// location of the PHPUnit command line script
define('PHPUNIT', dirname(dirname(__FILE__)) . '/phpunit');

// location of the PHPUnit framework folder
// define this if PHPUnit is not in the include path
define('PHPUNIT_DIR', dirname(dirname(__FILE__)) . '/phpunit');

//checking the directory here.
echo PHPUNIT_DIR;
die;//outputs E:\shared_www_root\www\tg\learning\php\unit_testing/phpunit which is the right path but \/? should there be back slashes?

// used for running single test cases
define('TEST_CASE_PREFIX', 'test_');

// used for variable decorator
define('TAB_WIDTH', '4');

// set this to true if you want to use Ajax requests with progressive test loading status
define('USE_AJAX', true);

/*EOF*/
I got the first line set right for the root directory of the tests because that got me past a page full of errors but now when I go to the index.php page in a browser I get a little box that says "no tests found. Please check out your config file." I grabbed a copy of a simple test from here http://www.phpunit.de/manual/current/en ... punit.html and I also dropped a copy of phpunit into the root directory and put that in the PHPUNIT_DIR config line.

I think the main things I'm confused about are "phpunit command line script", "test case prefix", and "Test suffix" Also please see the commented debug echo I put in for directory path. Looks wrong to me with back slashes.

Can anyone tell me how you would interpret this config file?

I have the directories set up with phpunit, phpuniwebui, and unit_tests all side by side in the unit_testing root directory.

Thank you

Re: phpunit testing framework and phpunitwebui

Posted: Thu Jul 21, 2011 11:57 pm
by iansane
Well I'm making progress. I managed to get the suffix and prefix stuff figured out. But now I have a missing class.

The test file had to be named someTest.php for the suffix part and the actual function being tested had to be test_somefunction().

So it is seeing the test but when I run it, it tells me PHPUnit_Framework_TestSuite not found on line 441 of functions.php. Well, I figured out that some other person wrote their own version of phpunit which is the one I got from source forge. No classes at all, just some functions thrown together.

I finally managed to figure out how to download from the correct source directly from the pear channel. http://pear.phpunit.de/

So now I'm trying to find the file that has that missing class since just pointing the config.php to the correct PHPUnit directory is still not working.

Re: phpunit testing framework and phpunitwebui

Posted: Fri Jul 22, 2011 9:36 am
by iansane
Last night I found that a entire script is missing from the latest version from pear.phpunit.de that is called from the phpunitwebui scripts. Investigating, I found that the version included in the phpunit package from my Ubuntu linux repository has the necessary file. So I'm narrowing it down that the person who wrote phpunitwebui must have wrote it for linux who has added some of their own files.

So, now I am getting a fatal error can not re declare class

The line throwing the error is

Code: Select all

class PHPUnit_Framework_TestSuite implements PHPUnit_Framework_Test, PHPUnit_Framework_SelfDescribing, IteratorAggregate{
//several lines of code here but it's the line above causing the error.
}
Now I've parsed through every file that is included or required in the above script and there is no other place where the class is already defined. Strange thing is that there are places where an object of that class is used which would mean that it has to be defined somewhere.

Re: phpunit testing framework and phpunitwebui

Posted: Wed Aug 03, 2011 4:22 am
by josh
Have you tried running it (phpunit) over the command line? Do you know how to open a command line? DO you know how to invoke the phpunit command? If you run it you will get a success message or a failure message with accompanying error. It sounds like you don't know how to use the command line? (don't be embarrassed) I take it on you're on windows? Maybe you double clicked the phpunit.bat & you saw the command window open & close really fast, too fast to read the output? Is this what you're observing?

Either way you need to get phpunit up & running before this web GUI is of any use.