Automatic testing in Streberπ
We use simpletest's web_tester module for testing. This emulates a browser and simulates real clickflows and checks the results. You can login, change a users password, logout and test if the new password is working. So this is more integration testing than unit testing. This is nice for:
- Tests are very easy to write.
- Since pixtur added sql fixtures you can test complex setup involving several users and projects.
- You can easily valid html structure, user data escaping and much more.
It fails on:
- Internal structures
Running the testsπ
The tests are executed when requesting `http://localhost/streber/tests/testsuite_pages.php`.
There are about 600 tests which take about 30 seconds on pixtur's notebook. Right now the tests uses database snapshots as sql-dumps as fixtures. These dumps are located at
. The testing sql tables get the prefix
so your userdata will not be resetted all the time. Initialization is done with the new class "TestEnvironment"
Creating new fixturesπ
Creating a new fixture is done with
. It writes a dump of all existing tables, so you have to remove the
-tables before calling this.
Updating fixtures databaseπ
The fixtures need to be updated every time, the database scheme (e.I. the database version) changes. If you don't do this, you will get errors like this:
Test and development databaseπ
To distinguish between the two databases, we overwrite the
before running the web_tester:
$this->addHeader('USER_AGENT: streber_unit_tester'); # will result in HTTP_USER_AGENT
we check for this user_agent and add the prefix
. Before each test_case the test-database is completely recreated. After running all tests, the tables with
will be dropped from the database by executing a long sql-statement:
Although the current setting already provides a lot of features, it's still pretty hackish. Following this should be adjusted:
- Streber should detect the web_tester user_agent and automatically use the
TestEnvironment should provide a method the clean up test tables.
- Setup basic project environment as fixture for testing.
Things that urgently need to be testedπ
- Form submitting esp for complex things like Tasks and People.
- Correct escaping of all user data.
- Item visibility in project environments.