forked from xzilla/phppgadmin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make selenium tests full dynamics, no more build_tests.php required.
- Loading branch information
Showing
19 changed files
with
1,261 additions
and
1,239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
selenium/tests/config.inc.php | ||
tests/selenium/config.test.php | ||
tests/selenium/TestSuite.html | ||
tests/selenium/static |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,47 @@ | ||
HowTo run the tests follow these steps : | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
HowTo run the tests | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
1. Create & configure your ./tests/selenium/config.test.php (See sample one in ./tests/selenium/config.inc.php-dist). | ||
2. Run the ./build_tests.php script | ||
This script builds the TestSuite.html file and all the related html tests files in ./tests/selenium/static/. | ||
It builds one directory for each server selected to run the tests in your ./tests/selenium/config.inc.php | ||
and creates the static selenium html test files for each of them. | ||
3. Open your browser and go to http://$webUrl/ | ||
Where $webUrl is the value set in your ./tests/selenium/config.inc.php | ||
4. Click on "Selenium tests" on the PPA intro page & run the tests using the "Selenium TestRunner" buttons in the top-right frame. | ||
2. Open your browser and go to http://$webUrl/ | ||
Where $webUrl is the value set in your ./tests/selenium/config.inc.php | ||
3. Click on "Selenium tests" on the PPA intro page & run the tests using the "Selenium TestRunner" buttons in the top-right frame. | ||
|
||
Enjoy the tests. | ||
|
||
|
||
HowTo write new tests: | ||
HowTo write new tests | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
The selenium's HTML tests files cannot behave differently in regard to the PG backend where the tests are run on. In order to address | ||
this issue we are using "test-builder" scripts to create these static HTML files. These scripts are connected to each backends using | ||
the PPA database classes and allow you to use their methods, and especialy the $data->has*() ones, throught the $data variable like | ||
in any other ppa script. | ||
|
||
1. how build_tests is working and why | ||
The build_tests.php script is processing the test-builders scripts from ./tests/selenium/src in alphanumeric order. That's why each | ||
Normaly, the selenium's statis HTML tests files cannot behave differently in regard to the PG backend where the tests are run on. In order to address | ||
this issue we are using PHP scripts that connect to each backends using the PPA database classes and allow you to use their methods, | ||
and especialy the $data->has*() ones, throught the $data variable like in any other ppa script. | ||
|
||
TestSuite.php is the test suite script that build the list of tests groups (top left frame). | ||
|
||
1. how TestSuite.php is working and why | ||
TestSuite.php script is processing the test-builders scripts from ./tests/selenium/src in alphanumeric order. That's why each | ||
test-builder's name should follow these rules: begin with 2numeric number, then -, then the script name (ex. 01-test1.php or 46-test46.php). | ||
|
||
It allows to enforce the order the scripts will be run during the testSuite. This way, column's tests could be run *after* the table's tests | ||
in the test suite and use the previous created tables. | ||
|
||
2. how test-builder are working | ||
|
||
These scripts are included and executed in the build_tests.php in alphanumeric order. | ||
They should: | ||
- begin with the declaration of the global values $testsuite_file and $test_static_dir which holds the paths to the TestSuite file | ||
and the static folder where the HTML tests files are created | ||
These scripts are included and executed in TestSuite.php in alphanumeric order. See comments in file ./tests/selenium/src/skeleton.php-dist | ||
which is a template of test-builder. | ||
When executed from TestSuite.php, test-builders should: | ||
- create a "TestBuilder" intance which gonna helps write HTML tests quickly. | ||
The constructor takes the following arguments: | ||
- server's label (from your config.inc.php) | ||
- HTML title of the page | ||
- Test description (appears on top of the tests table) | ||
|
||
$t = new TestBuilder($server['desc'], | ||
'Index tests', | ||
$t = new TestBuilder('Index tests', | ||
'Create/Drop an unique Index' | ||
); | ||
|
||
- once the TestBuilder instance is created, you can use it to write our tests. | ||
- In particular, you should use the login($username, $pass) and logout() methods to create appropriate steps to login/logout to the current | ||
- You should use the login($username, $pass) and logout() methods to create appropriate steps to login/logout to the current | ||
server. | ||
- Each selenium actions are mapped (or should be) as methods. As instance, if you want to use the clickAndWait action, you should call the | ||
clickAndWait($locator) method. For the assertText, assertText($selector, $value), etc... | ||
- Use the addComment method to show comments anywhere in the tests page. Usefull to explain whatthe next tests are going to do. | ||
|
||
- finish whith calling the TestBuilder's "writeTests" method which will create the selenium HTML test file in the static dir and append this | ||
new test file to the testSuite file. | ||
|
||
$t->writeTests("{$test_static_dir}/{$server['desc']}/view.html", $testsuite_file); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Build the test files for each servers in config.test.php | ||
*/ | ||
|
||
chdir('../..'); /* go back to root so we can include scripts */ | ||
|
||
function oops($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) { | ||
echo "</table><div>{$errmsg}</div>\n"; | ||
exit; | ||
} | ||
|
||
$_no_db_connection = true; /* load lib.inc.php without trying to connect */ | ||
|
||
require_once('./libraries/lib.inc.php'); | ||
require('./tests/selenium/config.test.php'); | ||
require_once('./classes/database/Connection.php'); | ||
|
||
$test_dir = './tests/selenium'; | ||
$test_src_dir = "{$test_dir}/src"; | ||
|
||
echo "<table border=\"1\"> | ||
<tr> | ||
<th>Test suite for PPA</th> | ||
</tr>\n"; | ||
|
||
$servers = $misc->getServers(); | ||
|
||
/* Loop on the servers given in the conf/config.inc.conf file */ | ||
foreach ($servers as $server) { | ||
// Is this server in our list of configured servers? | ||
if (!in_array($server['desc'], $test_servers)) | ||
continue; | ||
|
||
$fd = opendir($test_src_dir); | ||
$files = array(); | ||
while ($file = readdir($fd)) | ||
if (preg_match('@[0-9]+.*\.php$@', $file)) | ||
$files[] = $file; | ||
closedir($fd); | ||
sort($files); | ||
/* include the tests creator scripts here | ||
* in the order you want them executed. | ||
* Each script append itself to the TestSuite.html file. | ||
**/ | ||
foreach ($files as $testgroupfile) { | ||
require("{$test_src_dir}/{$testgroupfile}"); | ||
echo "<tr><td><a href=\"{$webUrl}/{$test_src_dir}/{$testgroupfile}?server={$server['id']}&run=1\">[{$server['desc']}] {$test_title}</a></td></tr>\n"; | ||
} | ||
} | ||
echo "</table>"; | ||
?> |
Oops, something went wrong.