Skip to content

Commit f4abab7

Browse files
test: DKM - Create individual test case for each prompt and capture execution time for each test case
2 parents 02b5528 + add344d commit f4abab7

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

tests/e2e-test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Installing Playwright Pytest from Virtual Environment
2323

2424
Run test cases
2525

26-
- To run test cases from your 'tests' folder : "pytest --html=report.html --self-contained-html"
26+
- To run test cases from e2e-test: "pytest --html=report.html --self-contained-html"
2727

2828
Create .env file in project root level with web app url and client credentials
2929

tests/e2e-test/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ python-dotenv
44
pytest-check
55
pytest-html
66
py
7+
beautifulsoup4

tests/e2e-test/tests/conftest.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from py.xml import html # type: ignore
1010
import io
1111
import logging
12+
from bs4 import BeautifulSoup
13+
import atexit
1214

1315

1416
@pytest.fixture(scope="session")
@@ -83,4 +85,29 @@ def pytest_collection_modifyitems(items):
8385
if hasattr(item, 'callspec'):
8486
prompt = item.callspec.params.get("prompt")
8587
if prompt:
86-
item._nodeid = prompt # This controls how the test name appears in the report
88+
item._nodeid = prompt # This controls how the test name appears in the report
89+
90+
def rename_duration_column():
91+
report_path = os.path.abspath("report.html") # or your report filename
92+
if not os.path.exists(report_path):
93+
print("Report file not found, skipping column rename.")
94+
return
95+
96+
with open(report_path, 'r', encoding='utf-8') as f:
97+
soup = BeautifulSoup(f, 'html.parser')
98+
99+
# Find and rename the header
100+
headers = soup.select('table#results-table thead th')
101+
for th in headers:
102+
if th.text.strip() == 'Duration':
103+
th.string = 'Execution Time'
104+
#print("Renamed 'Duration' to 'Execution Time'")
105+
break
106+
else:
107+
print("'Duration' column not found in report.")
108+
109+
with open(report_path, 'w', encoding='utf-8') as f:
110+
f.write(str(soup))
111+
112+
# Register this function to run after everything is done
113+
atexit.register(rename_duration_column)

0 commit comments

Comments
 (0)