Re: Unit tests requiring a database or other system specific infos
| From: | Wolfram Kriesing | Date: | Thu, 04 Sep 2003 14:23:11 +0000 |
| Subject: | Re: Unit tests requiring a database or other system specific infos | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-180@lists.php.net to get a copy of this message | ||
Daniel Khan wrote:
Hello List, I am currently writing unit tests for DB_NestedSet. For this tests access to a database is essential. I don't think that it's in the spirit of unit tests to require the user to hack around inside of the main test class to provide the credentials for the database access. So how can this be done? So I am seeing 2 possible ways atm: 1. The user provides a .ini file and passes this to the testscript. 2. I create a shellscript which asks for the credentials, creates a test database and runs the tests in it. Some packages in CPAN do this.i was also thinking about this for the last couple of days and i thought of something else: passing a parameter to the script (a get parameter, or alikes for a cmdline script) which the test script simply checks. The only thing here is that this parameter has to have a common name in order to automate tests. i.e. for automated tests, which is the smallest denominator, i guess - when running the test on a webserver, it could look like this: file_get_contents('http://my.server.org/pear/Package/tests/automted.php?dbDSN="mysql://user:pass@host/dbName"'); - running it as a command line, might look like this: file_get_contents('php Package/tests/automtedCmdLine.php dbDSN=mysql://user:pass@host/dbName'); or somehow like this. This leaves the flexibility to run the test automated and stall in case no dbDSN is given. The only definitions that need to made therefore are: - the parameter name(s), dbDSN might only be one that of them - the filename(s) and location that starts all the tests and returns a result such as 'success' and 'failed' or simply 0 or 1 my 2 cents -- Wolfram ... opensource @ vision:produktion ... http://opensource.visionp.de ... authentication system .... http://sf.net/projects/auth