Test Data Creation Suite
Some of the integration tests will require a basic set of data, including submissions and users, in order to operate. Creating this data should not always be in the scope of the test itself; it will make test cases lengthy and slow. Having a standardized set of sample data that tests can work with will permit tests to focus strictly on the testing, not on the data preparation.
Additionally, a representative suite of test data can be useful for workshops, presentations, etc.
Finally, since we support both MySQL and PostgreSQL, a proper testing environment will need to operate on both database platforms, without forcing the development team to separately maintain data for both.
For these reasons, it's desirable to script the creation, from scratch, of a sample database. The test data creation suite does that.
The suite uses Selenium Server to permit tools outside the browser environment to run activities within the browser. See the selection on Selenium Server (formerly Selenium RC Server) in Integration Testing for information on how to set this up.
Running the suite
- Create an empty database and grant access to a database user
- Create an empty files directory and set file permissions on it
- Have a handy PDF file that can be used for testing.
The details of these will be filled in below.
There are two elements to configure: the OJS configuration file, and the Selenium tests.
For the OJS configuration file, use the default template configuration file:
cp config.TEMPLATE.inc.php config.inc.php
This ensures that the installation form will come up when the suite is started.
For the Selenium tests, create a file in
tests/build/user-extensions.js using the template
lib/pkp/tests/build/user-extensions-TEMPLATE.js. This is where the database credentials etc. will be configured.
To execute the tests, run...
java -jar /path/to/selenium-server-standalone-2.42.2.jar -htmlsuite "*chrome" "http://url/to/index.php/" "tests/build/suite.html" "tests/results/result.html" -userExtensions "tests/build/user-extensions.js"
...replacing the Selenium jar file and local URL with the appropriate values for your environment.
Each time you run the test suite you'll have to ensure your environment suits the requirements set out above.
Note that the test suite can also be executed via the Selenium IDE. To run the scripts that way, ensure that the user extensions file is configured in the options dialog. Otherwise no special considerations are needed.