Getting started

For Kit Builders

Adding unit tests

You can add unit tests to your kits and execute them from the admin interface.

  1. 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.

  2. Edit your kit config's file to add a tests tool as below :

    [tools] tests = "SimpleTestTool"
  3. 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.

  4. 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.

  1. Write your test cases as above.

  2. Edit your kit's config file as below :

    [load_kits] n = "webappkit.simpletest.mysql" [tools] tests = "SimpleTestMysqlTool"
  3. 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"
  4. Go the kit's page to execute tests as above