Skip to content

Commit 588e13c

Browse files
fixture method practice
1 parent a361531 commit 588e13c

11 files changed

+56
-1
lines changed

PythonAutomationPractice/OOPSDemo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ def sub(self):
1919

2020

2121
obj = Calculator(5,4)
22+
print(obj)
898 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

pytestAutomation/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pytest
2+
3+
4+
@pytest.fixture()
5+
def setup():
6+
print('Setup method is executing')
7+
yield
8+
print('Yield method is executing.')
9+
10+
11+
@pytest.fixture()
12+
def dataLoad():
13+
print('User Profile data')
14+
return ["Proshanta", "Debnath", "deb@gmail.com"]
15+
16+
17+
@pytest.fixture(params=["chrome", "Firefox", "IE"])
18+
def crossBrowser(request):
19+
return request.param

pytestAutomation/test_Practice1.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
# Run any specific method on a file ---> py.test -k test_firstProgram -v -s
99
# we can mark(tag) test @pytest.mark.some and then run with -m
1010
# pytest.mark.xfail is used for not to show pass or failed status in reports
11+
# fixture are used as setup and tear down methods for test cases - conftest file to generalize
12+
# fixture is available all the test cases
13+
1114

1215
import pytest
1316

pytestAutomation/test_Practice2.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ def test_userProgram():
77

88

99
@pytest.mark.smoke
10-
def test_creditProgram():
10+
def test_creditProgram(setup):
1111
a = 4
1212
b = 6
1313
assert a + 2 == 6, "Addition not matched."
14+
15+
16+
def test_fixtureDemo(setup):
17+
print("FixtureDEMO method is executing")
18+
19+
20+
def test_crossBrowser(crossBrowser):
21+
print(crossBrowser)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
4+
@pytest.mark.usefixtures("dataLoad")
5+
class AutomationPractice:
6+
def editPorfile(self, dataLoad):
7+
print(dataLoad[0])
8+
print(dataLoad[1])
9+
10+
11+

0 commit comments

Comments
 (0)