E2E and manual tests for cinema project.
Test cases for manual testing are here.
- python
- selenium
- selenium grid
- requests
- pytest
- pytest plugins:
- pytest-xdist
- pytest-assume
- pytest-html
- allure
- testlink
In order to run tests it is required to set environmental variables:
env
variable which chooses SUT's (System Under Test) environment. There are currently 2 environments - staging and production. In order to run tests against staging environmentenv
variable should equalstaging
. To run tests against production environmentenv
variable should equalproduction
. Environments' test configuration can be found in config.ini file.
Tests which uses mailing system requires setting IMAP connection. It can be done by setting the following environmental variables.
email_login
- login to an email accountemail_passwd
- password to an email accountemail_host
- IMAP hostemail_port
- IMAP port
Tests which uses SQL queries requires establishing database connection. It can be done by setting the following environmental variables.
db_name
- database namedb_user
- database user logindb_password
- database passworddb_host
- database hostdb_port
- database port
Tests can be run using pytest
command.
Only tests which are marked as production should be run against production environment. These tests do not insert any
data into database. To run this kind of tests user should set env
variable to production
and
invoke pytest -k production
command.
Test supports pytest-html reports. To run tests with report
run pytest --html=<output__file_name.html> --self-contained-html
command. Report contains stacktrace, screen, and some
additional info (like application's page URL where error occurred or browser logs) for making debugging easier.
Repository contains example html report.
Test supports allure reports. To run tests with report run pytest --alluredir=.\allure_results
command. Report
contains stacktrace, screen, and some additional info (like application's page URL where error occurred or browser
cookies) for making debugging easier. In order to open report run allure serve .\allure_results
command.
For parallel tests execution tests uses pytest plugin - pytest-dist. To run tests in parallel user should
run pytest -n=<number of cpus>
command.
This project uses pytest's markers for choosing which tests needs to be run. The following markers are available:
- mail - used for marking tests which requires reading incoming emails
- production - used for marking tests which can be run only against production environment
Test supports integration with TestLink in the scope of marking tests as passed or failed within the build. Functionality uses TestLink-API-Python-client plugin. The following env variables are required:
TESTLINK_API_PYTHON_DEVKEY=[testlink API key]
TESTLINK_API_PYTHON_SERVER_URL=http://[testlink domain name]/testlink/lib/api/xmlrpc/v1/xmlrpc.php
Each test function name consists of 3 parts separated by _
:
test
prefix (required by pytest),- readable test case ID from TestLink (e.g.
c4
will be automatically converted to TestLink format:C-4
), - test case name (for easy test case identification),
For exampletest_c4_login_invalid_credentials
.
The following parameters are required:
- build (build name)
- testplan (test plan name)
Command example:
pytest -k test_c4_login_invalid_credentials --build="test build" --testplan="test plan 1"
Locators are written in UPPER_CASE. There are 2 types of locators in this project:
- static locators - locators which are used in standard way. Each static locator has 'S' as a postfix.
- dynamic locators - locators needs to be used with
dynamic_locator()
function. This function takes locator as an argument and value which will be injected to locator. Function accepts either positional arguments or keyword arguments (e.g.dynamic_locator((By.XPATH, '//a[contains(text(), "{}")]'), 'test')
- text 'test' will be inserted where the curly brackets are). Each dynamic locator has 'D' as a postfix.
Page names are written in CamelCase. Each page has 'P' as a postfix.
Tests use imaplib library and gmail account to handling incoming emails.
There are two types of fixtures in this project:
- standard fixtures which starts web browser
- requests fixtures which uses requests module (these kinds of fixtures do not require starting browser). Requests fixtures are used mainly for creating test data.
Description of the most important files and folders in this project.
- drivers - drivers for local tests execution,
- pom - page object model's classes,
- sql - SQL queries and execution function
- tests - test cases
- utils - classes for handling emails, date operations, and creating test data with requests
- config.ini - stores the most important variables (accounts credentials, Grid URL etc.)
- conftest.py - pytest fixtures shared among all tests
- driver.py - stores driver's configuration class and methods for updating driver's cookies
- env_data.py - reads config.ini file.
- pytest.ini - file for customising pytest behaviour
- requests_fixtures.py - fixtures which uses requests module
- requirements.txt - packages required for running tests environment