Creating automated tests discussion
| From: | Yavor Shahpasov | Date: | Wed, 16 Jul 2003 19:47:43 +0000 |
| Subject: | Creating automated tests discussion | ||
| Groups: | php.pear.qa | ||
| Request: | Send a blank email to pear-qa+get-68@lists.php.net to get a copy of this message | ||
I have started making a test suite for Auth with PHPUnit, I have made some progress,
my tests structures is as follows
I have a base class for container tests
TestAuthContainer.php which has an abstract method getContainer and a bunch of tests
(addUser,fetchData,removeUser,listsUsers etc), I extend the class for each container and implement
the getContainer and getExtaOptions methods. I also have a php file with the options for each test,
which is just included where required
>> file >> auth_container_db_options.php
$options = array(
'dsn'=>'pgsql://yavo:@localhost/projects',
'table'=>'users',
'usernamecol'=>'userlogin',
'passwordcol'=>'userpassword',
'db_fields'=>'*'
);
$extra_options['username'] = 'test_user';
$extra_options['passwd'] = 'test_user';
>>
and I have a file which creates the test suites and runs them
Some issues I want to disscuss
a) we need some common way of creating test suites, come coding style/structure, this should be
added to the developer docs somewere on the site,
a simple approach would be
for Dirs in PEAR/tests
if file Dirname/tests/runtest.php exists
run Dirname/tests/runtest.php
end if
end for
each package should have it's test suite in PEAR/tests/Package_Name/tests (which I belive is
the default behaviour), the developer would choose how to implement the test suite, but the
fallback is that he would also have to create an html test suite for it (runhtmltests.php)
alternative approach
create a test suite
for Dirs in PEAR/tests
for Files in Dir
if file starts with test
assume file contains a testCase class with the same name
instantiate the class and add it to the test suite
end if
end for
end for
run the test suite as appropriate, either as console or html
benefits with this approach are that the developer would not have to supply different test suites,
PEAR system will choose how to display the test results, depending on the user gui being used for
pear (console,gtk, html)
I hope I did not get too confusing above.
b) test suites need to implement at least one possible more run methods (ie console/html)
c)we need a new pear command (pear tests|test|runtest|runtests [PackageName]), if no package is
supplied all tests should be run else just tests for all packages
am sure there are more stuff but this will do for now.
Yavor
Attachment: [application/x-zip-compressed] auth_tests.zip
Attachment: [application/x-zip-compressed] auth_tests.zip