Adding unit tests
You can add unit tests to your kits and execute them from the admin interface.
-
Write test cases and put them somewhere into your kit. A
tests/
folder would be nice. Webappkit currently only support Simple Test, but other tests frameworks may be added in the future. -
Edit your kit config's file to add a
tests
tool as below :[tools] tests = "SimpleTestTool" -
Create a
tests.tool.ini
file at the root of the kit (just as for any tool's config file) And list your test cases as below :[classes] ; test_case_class = "path/to/file" firsttestcase = "tests/first.php" secondtestcase = "tests/second.php*"As you see, you can use the
.php*
trick to have separate test cases for each php version. -
Go on your kit's admin page on the admin interface to see unit tests results.
With a testing database
Sometimes you want to test code that use a database. If you don't want to use mock up and don't want to mess you real data either, SimpleTestMysqlTool
is for you. It is located within webappkit.simpletest.mysql
kit.
-
Write your test cases as above.
-
Edit your kit's config file as below :
[load_kits] n = "webappkit.simpletest.mysql" [tools] tests = "SimpleTestMysqlTool" -
Just as above, create a
tests.tool.ini
file and list your test cases. But you can also set a database connection, and put tables and data creation SQL queries that will be executed before your tests to set up the testing environment.[classes] ; your test cases there [db] host = "localhost" user = "" pwd = "" name = "unit_tests" ; unit tests database name encoding = "utf8" ; character encoding for database creation and connexion create = 1 ; if true, will try to create the database drop = 0 ; if true, will drop the database after tests [tables] table_name = "Table creation SQL query" ; set your table creation queries there. ; BE CAREFUL ! Those tables will be dropped each time you start your tests ! [data] n = "Data row creation SQL query" Go the kit's page to execute tests as above