Skip to content
Extraits de code Groupes Projets
Valider f8529971 rédigé par mattpiwik's avatar mattpiwik
Parcourir les fichiers

Refs #1446 Refs #818

 * Fixing unit tests on local box by ignoring ExampleAPI.getPiwikVersion which would fail at every new version

Note: on my box, when I run all_tests.php, I don't see the green bar at the bottom of the page anymore. It simply displays the Time and Memory delta. I didn't see any commit that coudl have broken this so I'm a bit confused as to why the green/red bar doesn't display anymore?

git-svn-id: http://dev.piwik.org/svn/trunk@2472 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent b2ab57a8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 66 ajouts et 58 suppressions
...@@ -32,6 +32,8 @@ class Test_Piwik_Integration_ExampleAPI extends Test_Integration ...@@ -32,6 +32,8 @@ class Test_Piwik_Integration_ExampleAPI extends Test_Integration
// one could generate fake inputs, and check that ouputs are processed as expected // one could generate fake inputs, and check that ouputs are processed as expected
// @see tests/integration/ for more info // @see tests/integration/ for more info
$this->setApiToCall( 'ExampleAPI' ); $this->setApiToCall( 'ExampleAPI' );
// Ignore the getPiwikVersion call which would otherwise fail at every new release
$this->setApiNotToCall( 'ExampleAPI.getPiwikVersion');
$renderers = Piwik_DataTable_Renderer::getRenderers(); $renderers = Piwik_DataTable_Renderer::getRenderers();
$this->callGetApiCompareOutput(__FUNCTION__, $renderers); $this->callGetApiCompareOutput(__FUNCTION__, $renderers);
} }
......
Le fichier a été supprimé par une entrée .gitattributes, ou son encodage n'est pas pris en charge.
<table id="ExampleAPI_getPiwikVersion" border="1">
<thead>
<tr>
<th>value</th>
</tr>
</thead>
<tbody>
<tr>
<td>0.6.3</td>
</tr>
</tbody>
</table>
{"value":"0.6.3"}
\ No newline at end of file
0.6.3
\ No newline at end of file
s:5:"0.6.3";
\ No newline at end of file
Le fichier a été supprimé par une entrée .gitattributes, ou son encodage n'est pas pris en charge.
<?xml version="1.0" encoding="utf-8" ?>
<result>0.6.3</result>
\ No newline at end of file
RUN TESTS Piwik comes with unit tests, integration tests, Javascript tests and Webtests.
========== This document briefly describes how to use and modify Piwik tests.
You can run all tests
http://dev.piwik.org/svn/trunk/tests/all_tests.php HOW TO RUN PIWIK TESTS
=======================
You can run one test file at a time by going to the test file directly You can run all tests by calling the file tests/all_tests.php
The file will run all unit tests and integration tests.
You can also run one test file at a time by executing the test file directly eg.
http://dev.piwik.org/svn/trunk/tests/core/DataTable.test.php http://dev.piwik.org/svn/trunk/tests/core/DataTable.test.php
CONTINOUS INTEGRATION
======================
We currently use continuous integration build server, located at:
http://bamboo.openx.org:8085/browse/PIWIK-TRUNK/
UNIT TESTs UNIT TESTs
=========== ===========
Piwik tests use the Simpletest Unit Testing framework. Piwik tests use the Simpletest Unit Testing framework.
Piwik unit tests suite can be found in the Piwik SVN: Piwik unit tests suite can be found in the Piwik SVN:
http://dev.piwik.org/svn/trunk/tests/ http://dev.piwik.org/svn/trunk/tests/
Plugins can also integrate unit tests, in a tests/ directory inside the plugin folder.
Check for example plugins/SitesManager/tests/ or plugins/UserCountry/tests/
INTEGRATION TESTS INTEGRATION TESTS
================== ==================
Located in tests/integration/. They generate hits to the Tracker (record visits and page views) Integration tests allow to test how major Piwik components interact together.
and then test all API responses and for each API output, check that they match expected XML. 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.
You can then use Text Compare softwares (eg. WinMerge on Win) to easily view changes. You can then use Text Compare softwares (eg. WinMerge on Win) to easily view changes.
The main test is located tests/integration/Main.test.php
See also http://dev.piwik.org/trac/ticket/1465
JAVASCRIPT TESTS JAVASCRIPT TESTS
================= =================
piwik.js is unit tested and you can run tests in piwik/tests/javascript/ piwik.js is unit tested and you can run tests in piwik/tests/javascript/
...@@ -33,6 +37,13 @@ piwik.js is unit tested and you can run tests in piwik/tests/javascript/ ...@@ -33,6 +37,13 @@ piwik.js is unit tested and you can run tests in piwik/tests/javascript/
The Installation process is also webtested. They are ran by the continuous integration server. The Installation process is also webtested. They are ran by the continuous integration server.
http://dev.piwik.org/svn/trunk/tests/webtest/testcases/level0/ http://dev.piwik.org/svn/trunk/tests/webtest/testcases/level0/
If you want to help, we are always looking to improve the Piwik code coverage! CONTINOUS INTEGRATION
======================
We currently use continuous integration build server, located at:
http://bamboo.openx.org:8085/browse/PIWIK-TRUNK/
PARTICIPATE
============
You can help by improving existing tests, or identify some missing tests and implement them.
See http://dev.piwik.org/trac/wiki/PiwikDevelopmentProcess#Howtosubmitapatch
Please contact us at hello@piwik.org Please contact us at hello@piwik.org
\ No newline at end of file
...@@ -94,14 +94,41 @@ abstract class Test_Integration extends Test_Database ...@@ -94,14 +94,41 @@ abstract class Test_Integration extends Test_Database
{ {
$apiToCall = array($apiToCall); $apiToCall = array($apiToCall);
} }
$this->apiToCall= $apiToCall; $this->apiToCall = $apiToCall;
}
/**
* Sets a list of API methods to not call during the test
* @param $apiNotToCall eg. 'ExampleAPI.getPiwikVersion'
* @return void
*/
protected function setApiNotToCall( $apiNotToCall )
{
if(!is_array($apiNotToCall))
{
$apiNotToCall = array($apiNotToCall);
}
$this->apiNotToCall = $apiNotToCall;
} }
protected $apiToCall = array(); protected $apiToCall = array();
/* // List of Modules, or Module.Method that should not be called as part of the XML output compare
// Usually these modules either return random changing data, or are already tested in specific unit tests.
protected $apiNotToCall = array(
'LanguagesManager',
'DBStats',
'UsersManager',
'SitesManager',
'ExampleUI',
'Live',
'SEO',
'ExampleAPI',
);
/**
* Checks that the response is a GIF image as expected. * Checks that the response is a GIF image as expected.
* * @return Will fail the test if the response is not the expected GIF
*/ */
protected function checkResponse($response) protected function checkResponse($response)
{ {
...@@ -183,19 +210,6 @@ abstract class Test_Integration extends Test_Database ...@@ -183,19 +210,6 @@ abstract class Test_Integration extends Test_Database
*/ */
protected function generateUrlsApi( $parametersToSet, $formats, $periods, $setDateLastN = false ) protected function generateUrlsApi( $parametersToSet, $formats, $periods, $setDateLastN = false )
{ {
// List of Modules, or Module.Method that should not be called as part of the XML output compare
// Usually these modules either return random changing data, or are already tester in specific unit tests.
// Live! should also be tested and its API finalized.
$apiNotToTest = array(
'LanguagesManager',
'DBStats',
'UsersManager',
'SitesManager',
'ExampleUI',
'Live',
'SEO',
'ExampleAPI',
);
// Get the URLs to query against the API for all functions starting with get* // Get the URLs to query against the API for all functions starting with get*
$skipped = $requestUrls = array(); $skipped = $requestUrls = array();
...@@ -208,19 +222,17 @@ abstract class Test_Integration extends Test_Database ...@@ -208,19 +222,17 @@ abstract class Test_Integration extends Test_Database
$apiId = $moduleName.'.'.$methodName; $apiId = $moduleName.'.'.$methodName;
// If Api to test were set, we only test these // If Api to test were set, we only test these
if(!empty($this->apiToCall)) if(!empty($this->apiToCall)
&& in_array($moduleName, $this->apiToCall) === false
&& in_array($apiId, $this->apiToCall) === false)
{ {
if(in_array($moduleName, $this->apiToCall) === false $skipped[] = $apiId;
&& in_array($apiId, $this->apiToCall) === false) continue;
{
$skipped[] = $apiId;
continue;
}
} }
// Excluded modules from test // Excluded modules from test
elseif(strpos($methodName, 'get') !== 0 elseif(strpos($methodName, 'get') !== 0
|| in_array($moduleName, $apiNotToTest) === true || in_array($moduleName, $this->apiNotToCall) === true
|| in_array($apiId, $apiNotToTest) === true) || in_array($apiId, $this->apiNotToCall) === true)
{ {
$skipped[] = $apiId; $skipped[] = $apiId;
continue; continue;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter