Switch branches/tags
Nothing to show
Find file History
Pull request Compare This branch is 6 commits ahead, 2545 commits behind ThinkUpLLC:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
classes
simpletest
testdata
README.textile
all_tests.php
config.tests.sample.inc.php
config_test.php
database_test.php
followdao_test.php
friends_paging_test.php
frontend_test.php
init.tests.php
log_test.php
longurlapi_test.php
mailer_test.php
mysqldao_test.php
plugindao_test.php
postdao_test.php
twitteroauth_test.php
userdao_test.php

README.textile

ThinkTank Tests

All code submitted to the repository should have corresponding tests that pass.

The test suite assumes there is a thinktank_tests database which the default ThinkTank db user can access. Each test should set up the appropriate test data in the setUp() method and drop those tables in the tearDown() method.

Running Tests

To run a particular test, like the UserDAO test, in the thinktank source code root folder, use this command:

$ php tests/userdao_test.php

To run all the tests, use:

$ php tests/all_tests.php

The webapp tests contained in tests/frontend_test.php assumes you have a local installation of ThinkTank and that it is using the thinktank_tests database. Make sure you update your config.inc.php to point to the thinktank_tests database before running the webapp tests.

Writing Tests

Best practices for writing tests are still getting developed. In the meantime, use some existing tests as examples.

DAO Tests

See userdao_test.php as an example of a set of DAO tests.

Web Page Tests

Add tests for particular pages inside the webapp to frontend_test.php.

Crawler Consumption Tests

To test consumption of data from web services, mock up the appropriate classes and store test data to local files.
For example, the classes/mock.TwitterOAuth.php class reads data from the files in the testdata directory.

Once your tests work, add them to the all_tests.php file to run along with the existing tests.