testlinktool Documentation
Transcription
testlinktool Documentation
testlinktool Documentation Release 1 vade-retro technology June 14, 2016 Contents 1 Documentation Française 1.1 Générer les tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Installation du framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Lancer les tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 3 4 2 English Docummentation 2.1 Generate tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Framework Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Launch tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7 7 8 3 unittest and selenium wrappers 3.1 selenium WLDM API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 TestLink runner and wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 11 11 4 Indices and tables 13 i ii testlinktool Documentation, Release 1 This tool provide you an easy-to-use API to deal with integration and system test with python. Then, we provide you an fast way to report them to the testlink test-management web service. We use python-unittest as a base framework, ‘selenium <http://docs.seleniumhq.org/>‘to deal with browsers and implement ‘testlink RPC API <http://www.testlink.org/>‘to report results. Contents 1 testlinktool Documentation, Release 1 2 Contents CHAPTER 1 Documentation Française 1.1 Générer les tests 1.2 Installation du framework Le framework de test est compatible python 2.7 et 3.4. Python 3.4 est fortement conseillé. L’installation du framework se fait selon l’une des méthodes standard dans l’écosystème python pip ou setup.py. Il est fortement conseillé de travailler dans un virtualenv 1.2.1 virtualenv Sur Linux (exemple pris sur ubuntu et autre debianlike) sudo apt-get install python-dev python3-dev sudo pip install virtualenv # allez dans le dossier adéquat, veillez à ne pas être en superutilisateur virtualenv nom_de_votre_virtualenv --python=python3 source nom_de_votre_virtualenv/bin/activate Sur Windows Ouvrez powershell et entrez (Invoke-WebRequest https://bitbucket.org/pypa/setuptools/raw/bootstrap/e | python3 Dézippez l’archive setuptools et entrez ensuite @python easy_install.py pip@ Redémarrez powershell en mode administrateur pour que l’environnement et PATH soient mis à jour. pip install virtualenv pip install virtualenvwrapper-powershell Set-ExecutionPolicy RemoteSigned set $env:WORKON_HOME Import-Module virtualenvwrapper # si powershell vous envoie une erreur, lancez la commande une second New-VirtualEnvironment nom_de_votre_virtualenv --no-site-packages fermez la fenêtre adminstrateur et relancez un powershell en utilisateur normal pour lancer workon nom_de_votre_virtualenv 3 testlinktool Documentation, Release 1 1.2.2 Installer avec pip Installez les dépendances à lxml: ..sourcecode:: bash sudo apt-get install libz-dev libxml2-dev libxslt-dev python3-dev Lancez simplement pip install git+https://github.com/vaderetro/testlink-test-wrapper 1.2.3 Installer avec setup.py svn co git+https://github.com/vaderetro/testlink-test-wrapper cd test_automation_framework/bin python setup.py install 1.3 Lancer les tests 1.3.1 Configurer et lancer Tout d’abord il vous faudra configurer le module à l’aide d’un fichier config.json qui se présente ainsi: { "TEST_MODULE": "tests", "TESTLINK_API_KEY": "your_key_as_hexadecimal_32_char_long_string", "CUSTOM_FIELD_NAME_LIST": [ "customfield1", "customfield_2" ], "MUST_CREATE_BUILD": false, //true if you want the runner to mark this run as a new build "TESTLINK_PROJECT_ID": 1124, "TESTLINK_SERVER": "http://testlink_address/testlink/lib/api/xmlrpc/v1/xmlrpc.php", "TESTLINK_PROJECT_NAME": "ProjectName", "TESTLINK_PLATFORM_NAME": "TestingPlatformName", "UI_TEST_KEYWORD": "UI"//optional, only if you want to filter the test cases by using a keyworld } Ensuite deux solutions s’offrent à vous : • soit vos tests sont dans un projet autonome et n’utilise pas d’import au sein de ce projet : la commande launch_testlink_test est utilisable comme le veut son manuel d’utilisation • soit vous intégrez le dossier dans lequel les tests sont lancés dans votre path ou créez un fichier tel que launch.py qui ne fera qu’importer et appeler testlinktool.main.lauchtestlinktests.launch Exemples from testlinktool.main.lauchtestlinktests import launch import logging from logging import FileHandler, Formatter handler = FileHandler("text_execution.log") handler.setFormatter(Formatter("[%(asctime)s]:%(levelname)s: %(name)s: %(message)s")) logging.getLogger().addHandler(handler) logging.getLogger().setLevel(logging.DEBUG) launch() 4 Chapter 1. Documentation Française testlinktool Documentation, Release 1 1.3.2 Manuel d’utilisation de la commande launch_testlink_test -h : usage: launch_testlink_test [-h] [-d] [-v] [-p PATTERN] [-u | -f] [-I EXT_IDS | -N NAME_PATTERN] Lauch test from test link repository optional arguments: -h, --help show this help message and exit -d, --virtual_display verbosity -v, --verbose verbosity 1.3. Lancer les tests 5 testlinktool Documentation, Release 1 6 Chapter 1. Documentation Française CHAPTER 2 English Docummentation 2.1 Generate tests A tool is provided so that you can import and generate a test skeleton from testlink service. This is available from a simple commandline generate_testlink_test on your test root directory. 2.2 Framework Installation This framework is based on Python 3. Lower version are not supported. 2.2.1 virtualenv Linux Systems (Ubuntu 14+ and other debian-like example) sudo apt-get install python-dev python3-dev sudo pip install virtualenv # go to the directory you want to handle the environment. Ensure not being logged as root. virtualenv virtualenv_name --python=python3 source virtualenv_name/bin/activate On Windows Open powershell and launch (Invoke-WebRequest https://bitbucket.org/pypa/setuptools/raw/bootstrap/e | python3 Extract binaries and install setuptools. Then @python easy_install.py pip@ Restart powershell as administrator pip install virtualenv pip install virtualenvwrapper-powershell Set-ExecutionPolicy RemoteSigned set $env:WORKON_HOME Import-Module virtualenvwrapper # it could need to be launched twice New-VirtualEnvironment virtualenv_name --no-site-packages As a not-privileged user you can now use workon virtualenv_name. 7 testlinktool Documentation, Release 1 2.2.2 Install with pip You need to install lxml dependencies: ..sourcecode:: bash sudo apt-get install libz-dev libxml2-dev libxslt-dev python3-dev Just use pip install test-automation-framework 2.2.3 Install with setup.py git clone https://github.com/VadeRetro/test-automation-framework cd test-automation-framework python setup.py install 2.3 Launch tests 2.3.1 Basic configuration Everything is handled by a config.json file as this one: { "TEST_MODULE": "tests", "TESTLINK_API_KEY": "your_key_as_hexadecimal_32_char_long_string", "CUSTOM_FIELD_NAME_LIST": [ "customfield1", "customfield_2" ], "MUST_CREATE_BUILD": false, //true if you want the runner to mark this run as a new build "TESTLINK_PROJECT_ID": 1124, "TESTLINK_SERVER": "http://testlink_address/testlink/lib/api/xmlrpc/v1/xmlrpc.php", "TESTLINK_PROJECT_NAME": "ProjectName", "TESTLINK_PLATFORM_NAME": "TestingPlatformName", "UI_TEST_KEYWORD": "UI"//optional, only if you want to filter the test cases by using a keyworld } Basically you can use two ways : • Your tests are autonomous or everything you depends on is in your PATH : launch_testlink_test is here for you. It will use the config.json in current working dir. • You need to use non registered dependencies or centralize every commands: testlinktool.main.lauchtestlinktests.launch just import and call Example from testlinktool.main.lauchtestlinktests import launch import logging from logging import FileHandler, Formatter handler = FileHandler("text_execution.log") handler.setFormatter(Formatter("[%(asctime)s]:%(levelname)s: %(name)s: %(message)s")) logging.getLogger().addHandler(handler) logging.getLogger().setLevel(logging.DEBUG) launch() 8 Chapter 2. English Docummentation testlinktool Documentation, Release 1 2.3.2 Command man launch_testlink_test -h : usage: launch_testlink_test [-h] [-d] [-v] [-p PATTERN] [-u | -f] [-I EXT_IDS | -N NAME_PATTERN] Lauch test from test link repository optional arguments: -h, --help show this help message and exit -d, --virtual_display -v, --verbose verbosity 2.3. Launch tests 9 testlinktool Documentation, Release 1 10 Chapter 2. English Docummentation CHAPTER 3 unittest and selenium wrappers 3.1 selenium WLDM API 3.1.1 Test ojects 3.1.2 WLDM selenium wrapper API 3.1.3 Test callback system and decorator 3.2 TestLink runner and wrappers 11 testlinktool Documentation, Release 1 12 Chapter 3. unittest and selenium wrappers CHAPTER 4 Indices and tables • genindex • modindex • search 13