|Teknikode 6c3fa50c75 Added stats to repo, and adding tracking to downloads||7 years ago|
|README.md||7 years ago|
We use Travis CI for our continuous integration server. It automatically runs our battery of thousands of unit/integration/screenshot tests after each commit to our GIT repo. More information at the links:
Each core Piwik developer is responsible to keep the build green. If a developer breaks the build, he will receive an email from Travis CI.
The next section explains how you can run the test suite on your own dev machine.
To run tests, you must use the Git master. Tests files are not in the Piwik zip archive.
You can get the latest Git revision at: http://github.com/piwik/piwik
$ git clone https://github.com/piwik/piwik.git
Next install Composer which will lets you download the libraries used in Piwik:
$ curl -sS https://getcomposer.org/installer | php $ php composer.phar install
To execute the tests:
In your php.ini make sure you have the setting to show all errors:
error_reporting = E_ALL | E_STRICT
Go to tests/index.html to see the tests homepage and run the Integration tests via a visual UI, or run JS Tests
Next you will need to install PHPUnit
To install PHPUnit, run
php composer.phar update in the Piwik root directory.
Add the PHPUnit binary path to the your PATH environment variable. For example on Linux:
.bashrc in your home directory and add the following line:
You will need to source your
.bashrc or logout/login (or restart the terminal) for the changes to take effect.
To source your
.bashrc, in your home directory simply type
$ source .bashrc
See PHPUnit doc.
Note: if you were already using PHPUnit using PEAR, you may delete the PEAR PHPUnit with
sudo rm /usr/bin/phpunit
Configure PHPUnit: Copy the file
In this file, you will find the following lines.
Please edit HTTP_HOST and REQUEST_URI to match the hostname and path of the Piwik files.
For example if your Piwik is available at http://localhost/path/to/piwik/ you would write:
<server name="HTTP_HOST" value="localhost"/> <server name="REQUEST_URI" value="/path/to/piwik/"/>
[database_tests] section in
piwik/config/config.php.ini is set up correctly,
i.e. with the correct password to prevent the following error:
SQLSTATE  Access denied for user 'root'@'localhost' (using password: NO)
Run the tests
$ cd /path/to/piwik/tests/PHPUnit $ phpunit --group Core
$ phpunit --group Plugins $ phpunit --group Integration
There are three main groups of tests: Core, Plugins and Integration
For example run
phpunit --group Core
to run all Core Piwik tests.
Write more tests :) See “Writing Unit tests with PHPUnit”
Integration tests files are in
Integration tests allow to test how major Piwik components interact together. A test will typically generate hits to the Tracker (record visits and page views) and then test all API responses and for each API output. It then checks that they match expected XML (or CSV, json, etc.). If a test fails, you can compare the processed/ and expected/ directories in a graphical text compare tool, such as WinMerge on Win, or MELD on Linux, to easily view changes between files.
For example using Meld, click on “Start new comparison”, “Directory comparison”, in “Original” select “path/to/piwik/tests/PHPUnit/Integration/expected” in “Mine” select “path/to/piwik/tests/PHPUnit/Integration/processed”
If changes are expected due to the code changes you make, simply copy the file from processed/ to expected/, and test will then pass. Copying files is done easily using Meld (ALT+LEFT). Otherwise, if you didn’t expect to modify the API outputs, it might be that your changes are breaking some features unexpectedly.
As part of our integration tests we generate the scheduled reports (in HTML, PDF & SMS).
Some of these scheduled reports contain PNG graphs. Depending on the system under test, generated images can differ.
Therefore, PNG graphs are only tested and compared against “expected” graphs, if the system under test has the same characteristics as the integration server.
The characteristics of the integration server are described in
See tests/README.testing-data.md to import testing data in Piwik.
You can retrieve the files generated during the build (the build artifacts) at builds-artifacts.piwik.org
By default tests running on Travis CI will log all messages of at least
INFO level in
$PIWIK_ROOT_DIR/tmp/logs/piwik.log. In a given travis build output, you can view the logs by clicking on the line
$ cat $PIWIK_ROOT_DIR/tmp/logs/piwik.log at the end of the build output text.
VERBOSE messages are not logged by default (to keep Travis page loading fast). At any time you can temporarirly enable logging by modifying this file and changing
log_level = info to
log_level = debug or
log_level = verbose.
The screenshot tests generated by the continuous integration server are uploaded in builds-artifacts.piwik.org/ui-tests.master/
See tests/README.troubleshooting.md for troubleshooting the tests.
See tests/PHPUnit/Benchmarks/README.md to learn about running Benchmark tests.
See tests/README.xhprof.md for help on how to profile Piwik with XHProf.