diff --git a/.gitignore b/.gitignore index afb1aa4..ea622f5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,15 @@ screenshots/ *.pyc geckodriver.log .vscode/settings.json -/allure-results/ +allure-reports +allure-results .DS_Store .AppleDouble /framework/practice.py +.pytest_cache +tests/.pytest_cache +tests/negative_tests/.pytest_cache +tests/positive_tests/.pytest_cache diff --git a/Dockerfile b/Dockerfile index f160948..0ae1299 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,13 +22,16 @@ RUN pip install "poetry==$POETRY_VERSION" # Copy the poetry files to speed up builds. WORKDIR /code -COPY poetry.lock pyproject.toml ./ +COPY poetry.lock pyproject.toml docker-compose.yml ./ # Install dependencies via Poetry. RUN poetry config virtualenvs.create false \ && poetry install --no-interaction --no-ansi # Copy the source code into the image. +RUN mkdir allure-reports +RUN mkdir allure-results COPY framework ./framework COPY tests ./tests COPY pytest.ini ./ + diff --git a/Jenkinsfile b/Jenkinsfile index 4152c1a..9d5eceb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,25 +1,34 @@ pipeline { - agent any environment { - HEADLESS = '-e RUN_HEADLESS=True' RUN_HEADLESS = 'True' + HEADLESS = '-e RUN_HEADLESS=True' } - stages { stage("create docker image") { steps { echo "========== start building image ==========" - sh "docker build -t web_test ." -// sh "env" -// sh "docker run --rm $HEADLESS web_test pytest" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/negative_tests/test_authorization_user_negative.py" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_making_orders_positive.py" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_search_module_operation.py" - sh "docker run --rm -e RUN_HEADLESS=True web_test pytest -s tests/positive_tests/test_registration_and_authorization_positive.py" + sh "docker build -t web_test ." + sh "docker run -e RUN_HEADLESS=True --name example1 web_test pytest -s tests/negative_tests/test_authorization_user_negative.py" + sh "docker cp example1:/code/allure-results/ ${WORKSPACE}/" + sh "docker rm example1" + echo "========== finish building image ==========" + } + } + stage('reports') { + steps { + script { + allure([ + includeProperties: false, + jdk: '', + properties: [], + reportBuildPolicy: 'ALWAYS', + results: [[path: 'allure-results']] + ]) + } } } + } } - diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..39c9459 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' + +services: + allure: + image: "frankescobar/allure-docker-service" + environment: + CHECK_RESULTS_EVERY_SECONDS: 1 + KEEP_HISTORY: 1 + ports: + - "5050:5050" + volumes: + - ${PWD}/allure-results:/app/allure-results + - ${PWD}/allure-reports:/app/default-reports + + allure-ui: + image: "frankescobar/allure-docker-service-ui" + environment: + ALLURE_DOCKER_PUBLIC_API_URL: "http://localhost:5050" + ALLURE_DOCKER_PUBLIC_API_URL_PREFIX: "" + ports: + - "5252:5252" \ No newline at end of file diff --git a/framework/features/automationpractice/data/data_user_for_registration.py b/framework/features/automationpractice/data/data_user_for_registration.py index f6f936b..bce95b7 100644 --- a/framework/features/automationpractice/data/data_user_for_registration.py +++ b/framework/features/automationpractice/data/data_user_for_registration.py @@ -37,5 +37,5 @@ class DataUserForRegistration: EMAIL_ADDRESS_WITHOUT_DOMAIN = 'email_without_domain@' EMAIL_ADDRESS_WITHOUT_AT = 'email_without_atgmail.com' EMAIL_ADDRESS_WITHOUT_DOT = 'email_without_dot@gmailcom' - EMAIL_ADDRESS_WITH_SPEC_CHARACTER = 'email_with_t№$@gmailcom' + EMAIL_ADDRESS_WITH_SPEC_CHARACTER = 'email_with_spec_chraracter_№$@gmailcom' diff --git a/framework/utils.py b/framework/utils.py index a70f1af..ffc52e6 100644 --- a/framework/utils.py +++ b/framework/utils.py @@ -8,8 +8,6 @@ from selenium.webdriver.support.select import Select - - class SeleniumBase: def __init__(self, driver, locator=None): self.driver = driver diff --git a/poetry.lock b/poetry.lock index 9844306..790f05b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -129,7 +129,7 @@ python-versions = "*" [[package]] name = "faker" -version = "13.15.0" +version = "13.15.1" description = "Faker is a Python package that generates fake data for you." category = "main" optional = false @@ -160,7 +160,7 @@ python-versions = ">=3.6" [[package]] name = "identify" -version = "2.5.1" +version = "2.5.2" description = "File identification library for Python" category = "main" optional = false @@ -663,10 +663,7 @@ h11 = [ {file = "h11-0.13.0-py3-none-any.whl", hash = "sha256:8ddd78563b633ca55346c8cd41ec0af27d3c79931828beffb46ce70a379e7442"}, {file = "h11-0.13.0.tar.gz", hash = "sha256:70813c1135087a248a4d38cc0e1a0181ffab2188141a93eaf567940c3957ff06"}, ] -identify = [ - {file = "identify-2.5.1-py2.py3-none-any.whl", hash = "sha256:0dca2ea3e4381c435ef9c33ba100a78a9b40c0bab11189c7cf121f75815efeaa"}, - {file = "identify-2.5.1.tar.gz", hash = "sha256:3d11b16f3fe19f52039fb7e39c9c884b21cb1b586988114fbe42671f03de3e82"}, -] +identify = [] idna = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, diff --git a/pyproject.toml b/pyproject.toml index 20998a0..deac12c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,7 @@ loguru = "^0.6.0" Faker = "^13.15.0" pytest-rerunfailures = "^10.2" + [tool.poetry.dev-dependencies] [build-system] diff --git a/pytest.ini b/pytest.ini index ec7de5c..5884876 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,4 @@ [pytest] -addopts = -v --reruns=5 +addopts =-v --reruns=5 --alluredir=allure-results/ + diff --git a/tests/negative_tests/test_authorization_user_negative.py b/tests/negative_tests/test_authorization_user_negative.py index 85730a1..1547de3 100644 --- a/tests/negative_tests/test_authorization_user_negative.py +++ b/tests/negative_tests/test_authorization_user_negative.py @@ -1,10 +1,12 @@ - +import allure import pytest from framework.features.automationpractice.automationpractice_app import AutomationpracticeApp from framework.features.automationpractice.data.data_user_for_registration import DataUserForRegistration @pytest.mark.usefixtures("set_up_webdriver") class TestAuthorizationRegistrationNegative: + @allure.description("In that test we try login with invalid credentials") + @allure.severity(severity_level="CRITICAL") def test_authorization_with_invalid_credentials_negative(self): automation_practice = AutomationpracticeApp(self.driver) sign_in = automation_practice.sign_in_page @@ -13,18 +15,18 @@ def test_authorization_with_invalid_credentials_negative(self): sign_in.assert_authentication_failed() - - @pytest.mark.parametrize('email', [ - DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOMAIN, - DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_AT, - DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOT, - DataUserForRegistration.EMAIL_ADDRESS_WITH_SPEC_CHARACTER - ]) - def test_registration_with_invalid_data_in_email_address_negative(self,email): - automation_practice = AutomationpracticeApp(self.driver) - sign_in = automation_practice.sign_in_page - automation_practice.go_to("index.php?controller=authentication&back=my-account") - sign_in.registration_with_invalid_email(email) - sign_in.assert_invalid_email_address() + # @allure.description("In that test we try to registration with invalid data in email address") + # @pytest.mark.parametrize('email', [ + # DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOMAIN, + # DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_AT, + # DataUserForRegistration.EMAIL_ADDRESS_WITHOUT_DOT, + # DataUserForRegistration.EMAIL_ADDRESS_WITH_SPEC_CHARACTER + # ]) + # def test_registration_with_invalid_data_in_email_address_negative(self,email): + # automation_practice = AutomationpracticeApp(self.driver) + # sign_in = automation_practice.sign_in_page + # automation_practice.go_to("index.php?controller=authentication&back=my-account") + # sign_in.registration_with_invalid_email(email) + # sign_in.assert_invalid_email_address()