diff --git a/scripts/functional-tests/README b/scripts/functional-tests/README new file mode 100644 index 000000000..bf555fcf0 --- /dev/null +++ b/scripts/functional-tests/README @@ -0,0 +1,83 @@ +Functional Tests +================ + +.. sectnum:: + +:Author: Pablo Fernández de la Cigoña Nóvoa +:Contact: pcigonha@igalia.com +:Date: 05/08/2011 +:Copyright: + Some rights reserved. This document is distributed under the Creative + Commons Attribution-ShareAlike 3.0 licence, available in + http://creativecommons.org/licenses/by-sa/3.0/. +:Abstract: + Basic documentation about NavalPlan functional tests usage. + + +.. contents:: Table of Contents + + +Introduction +------------ + +Inside ``scripts/functional-tests/`` folder of NavalPlan source code, you can find +several scripts to test the correct performance of NavalPlan. There are functional tests +for all all the data types and all most all the administration options. + +Every file is called like _test.sah and represent all kind of tests made for +each individual option from the menu, all the files includes all the test to be done, +but the are some common tests for all of them: + +* Create +* Create with duplicate type (most be failure) +* Create with empty type (most be failure) +* Create with duplicate name (most be failure) +* Edit +* Delete + + +Requirements +------------ + +To run these test it's necessary to have installed Sahi + +You can download it at: + URL: ``http://sourceforge.net/projects/sahi/files/sahi-v35/20110719/install_sahi_v35_20110719.jar/download`` + +To install it, execute the following command where you have the previously download file + $ java -jar install_sahi_v35_XXXXXXXX.jar + +You can also see the instructions in sahi's page at: + URL: ``http://sahi.co.in/w/using-sahi`` + +* NOTE: If you are using firefox5 you must change this file ``/htdocs/spr/concat.js`` there replace: + + ``Sahi.prototype._isFF4 = function () {return /Firefox\/4|Iceweasel\/4|Shiretoko\/4/.test(this.navigator.userAgent);};`` + for: + ``Sahi.prototype._isFF4 = function () {return /Firefox\/4|Iceweasel\/4|Shiretoko\/4|Firefox\/5|Iceweasel\/5|Shiretoko\/5/.test(this.navigator.userAgent);};`` + +You can also see the instructions in sahi's page at: + URL: ``http://sahi.co.in/forums/viewtopic.php?id=2578`` + + +Run the Scripts +--------------- + +Once installed the program you have two kinds of run: + +* Graphical: Follow the instructions at + URL: ``http://sahi.co.in/w/using-sahi`` + +* Console: including the following sentence in your ``.bashrc`` + + $ export PATH=$PATH:/userdata/bin + + and then you can run the test like: + + $ testrunner.sh yourtest.sah [Initial url] [browser] + + It's possible run more than one script at the same time using a file.suite you can see some information in: + URL: ``http://sahi.co.in/w/Running+multiple+tests+in+batch+mode`` + +See more information about how to run at: + URL: ``http://sahi.co.in/w/using-sahi`` diff --git a/scripts/functional-tests/common_functions.sah b/scripts/functional-tests/common_functions.sah new file mode 100644 index 000000000..52b3b89f1 --- /dev/null +++ b/scripts/functional-tests/common_functions.sah @@ -0,0 +1,81 @@ +/* + * This file is part of NavalPlan + * + * Copyright (C) 2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/* Function to login in NavalPlan */ +function commonLogin($user, $password) { + _setValue(_textbox("j_username"), $user); + _setValue(_password("j_password"), $password); + _click(_submit("Log in")); +} + +/* Function to logout in NavalPlan */ +function commonLogout() { + _click(_link("[Log out]")); +} + +/* Function to access to create form */ +function commonCreate($something) { + _click(_link($something)); + _click(_cell("Create")); +} + +/* Function to edit something */ +function commonEdit($name, $cell) { + _click(_image("ico_editar1.png", _in(_cell($cell, _near(_cell($name)))))); +} + +/* Function to delete something */ +function commonDelete ($something, $name, $cell) { + _click(_link($something)); + _click(_image("ico_borrar1.png", _in(_cell($cell, _near(_cell($name)))))); + _click(_cell("OK")); +} + +/* Create new project */ +function commonCreateProject($name){ + _click(_link("Projects")); + _click(_image("ico_add.png")); + _setValue(_textbox(6), $name); + _click(_cell("Accept")); + _click(_image("ico_save.png")); +} + +/* Delete a project */ +function commonDeleteProject($name){ + _click(_link("Projects")); + _click(_image("ico_borrar1.png", _in(_cell(8, _near(_cell($name)))))); + _click(_cell("OK")); + _assertExists(_div("Removed "+$name)); + _assert(_isVisible(_div("Removed "+$name))); + _assertEqual("Removed "+$name, _getText(_div("Removed "+$name))); +} + +/* test to check a correct save */ +function commonSaveValidation($something, $name){ + _assertExists(_div($something+" \""+$name+"\" saved")); + _assert(_isVisible(_div($something+" \""+$name+"\" saved"))); + _assertEqual($something+" \""+$name+"\" saved", _getText(_div($something+" \""+$name+"\" saved"))); +} + +/* test to check a correct delete */ +function commonDeleteValidation($something, $name){ + _assertExists(_div($something+" \""+$name+"\" deleted")); + _assert(_isVisible(_div($something+" \""+$name+"\" deleted"))); + _assertEqual($something+" \""+$name+"\" deleted", _getText(_div($something+" \""+$name+"\" deleted"))); +}