Skip to content

Commit 02d167f

Browse files
committed
add allure to reports
1 parent d3831a3 commit 02d167f

5 files changed

Lines changed: 63 additions & 16 deletions

File tree

.github/workflows/main.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,34 @@ jobs:
2121
- name: Install GeckoDriver
2222
run: |
2323
python -m pip install webdriver-manager
24-
- name: Run tests
24+
- name: Install Allure
25+
run: |
26+
wget https://github.com/allure-framework/allure2/releases/download/2.25.0/allure-2.25.0.zip
27+
unzip allure-2.25.0.zip
28+
export PATH=$PATH:$(pwd)/allure-2.25.0/bin
29+
echo "PATH=$PATH" >> $GITHUB_ENV
30+
- name: Run tests with Allure
31+
env:
32+
PYTHONPATH: .
33+
run: |
34+
mkdir -p allure-results
35+
pytest test/ --alluredir=allure-results -v
36+
- name: Generate Allure report
37+
run: |
38+
allure generate allure-results -o allure-report --clean
39+
- name: Upload Allure report
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: allure-report
43+
path: allure-report/
44+
- name: Run tests with HTML (optional, for backward compat)
2545
env:
2646
PYTHONPATH: .
27-
run: pytest test/ --html=reports/report.html --self-contained-html
28-
- name: Upload test report
47+
run: |
48+
mkdir -p reports
49+
pytest test/ --html=reports/report.html --self-contained-html
50+
- name: Upload HTML test report
2951
uses: actions/upload-artifact@v4
3052
with:
31-
name: test-report
53+
name: html-report
3254
path: reports/report.html

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
selenium==4.35.0
22
pytest==8.4.2
33
pytest-html==4.1.1
4-
webdriver-manager==4.0.2
4+
webdriver-manager==4.0.2
5+
allure-pytest== 2.15.0

test/test_cart.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import allure
23
from selenium import webdriver
34
from selenium.webdriver.firefox.service import Service
45
from selenium.webdriver.firefox.options import Options as FirefoxOptions
@@ -68,19 +69,29 @@ def test_start_checkout(cart_page_with_items):
6869
print(f"Current URL after checkout: {cart_page_with_items.driver.current_url}")
6970

7071
@pytest.mark.parametrize("first_name, last_name, postal_code", [("Juanito", "Alimana", "1969"), ("Procura", "Peralta", "1997")])
71-
7272
def test_full_e2e_checkout(cart_page_with_items, first_name, last_name, postal_code):
73+
with allure.step("Iniciar checkout desde carrito"):
74+
assert cart_page_with_items.is_checkout_button_visible() == True
7375
cart_page_with_items.start_checkout()
7476
print(f"URL after start: {cart_page_with_items.driver.current_url}")
7577
time.sleep(2)
7678
assert "checkout-step-one.html" in cart_page_with_items.driver.current_url
79+
80+
with allure.step(f"Llenar info de checkout con {first_name} {last_name}"):
7781
time.sleep(1) # Extra buffer for DOM
7882
checkout = CheckoutPage(cart_page_with_items.driver)
7983
checkout.fill_info(first_name, last_name, postal_code)
84+
85+
with allure.step("Continuar a overview y verificar URL"):
8086
assert checkout.continue_to_overview() == True
8187
assert "checkout-step-two.html" in checkout.driver.current_url
88+
89+
with allure.step("Completar checkout y verificar éxito"):
8290
assert checkout.complete_checkout() == True
8391
assert "checkout-complete.html" in checkout.driver.current_url
8492
assert "Thank you for your order!" in checkout.driver.page_source
8593
print(f"E2E complete with user {first_name} {last_name}, final URL: {checkout.driver.current_url}")
8694

95+
allure.attach(cart_page_with_items.driver.get_screenshot_as_png(), name="Checkout Complete",
96+
attachment_type=allure.attachment_type.PNG)
97+

test/test_inventory.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import allure
23
from selenium import webdriver
34
from selenium.webdriver.firefox.service import Service
45
from selenium.webdriver.firefox.options import Options as FirefoxOptions
@@ -43,19 +44,22 @@ def test_add_product_to_cart(inventory_page):
4344

4445
def test_multi_add(inventory_page):
4546
products = ["bike_light", "backpack", "fleece_jacket"]
46-
inventory_page.add_multiple_products(products)
47-
badge = int(inventory_page.get_cart_badge_count())
48-
assert badge == 3
47+
with allure.step(f"Iniciar adición de {len(products)} productos al carrito"):
48+
inventory_page.add_multiple_products(products)
4949

50+
with allure.step("Verificar badge del carrito actualizado"):
51+
badge = int(inventory_page.get_cart_badge_count())
52+
assert badge == 3
53+
allure.attach(f"Badge final: {badge}", name="Badge Count", attachment_type=allure.attachment_type.TEXT)
5054
@pytest.mark.parametrize("sort_option, expected_order", [("lohi", "asc"), ("hilo", "desc")])
5155

5256
def test_sort_order(inventory_page, sort_option, expected_order):
53-
prices_before = inventory_page.get_prices()
54-
inventory_page.sort_by_price(sort_option)
55-
prices_after = inventory_page.get_prices()
56-
assert len(prices_after) == 6
57-
expected_sorted = sorted(prices_before, reverse=(expected_order == "desc"))
58-
assert prices_after == expected_sorted
57+
prices_before = inventory_page.get_prices()
58+
inventory_page.sort_by_price(sort_option)
59+
prices_after = inventory_page.get_prices()
60+
assert len(prices_after) == 6
61+
expected_sorted = sorted(prices_before, reverse=(expected_order == "desc"))
62+
assert prices_after == expected_sorted
5963

6064
def test_get_prices(inventory_page):
6165
prices = inventory_page.get_prices()

test/test_login.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import allure
23
from selenium import webdriver
34
from selenium.webdriver.firefox.service import Service
45
from selenium.webdriver.firefox.options import Options as FirefoxOptions
@@ -25,13 +26,21 @@ def login_page(request):
2526

2627

2728
def test_successful_login(login_page):
29+
with allure.step("Abrir página de login"):
2830
login_page.open_page()
31+
32+
with allure.step("Ingresar username válido"):
2933
login_page.insert_user_name(config_for_login_page.CREDENTIALS["standard_user"]["username"])
34+
35+
with allure.step("Ingresar password válido"):
3036
login_page.insert_password(config_for_login_page.CREDENTIALS["standard_user"]["password"])
37+
38+
with allure.step("Hacer clic en login y verificar redirección"):
3139
login_page.click_login_button()
3240
assert login_page.driver.current_url == "https://www.saucedemo.com/inventory.html"
33-
login_page.logout()
3441

42+
with allure.step("Cerrar sesión para cleanup"):
43+
login_page.logout()
3544

3645
def test_locked_out_user(login_page):
3746
login_page.open_page()

0 commit comments

Comments
 (0)