Skip to content

Commit 4ff36c1

Browse files
authored
Release 0 9 5 (#24)
* release v0.9.5 * release v0.9.5 * release v0.9.5
1 parent 5edef2b commit 4ff36c1

3 files changed

Lines changed: 193 additions & 2 deletions

File tree

.github/workflows/python-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip
32+
echo $PWD
3233
pip install build
3334
- name: Build package
3435
run: python -m build

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
print(f"installing from {app_path}")
99

1010

11-
with open("README.md", "rt") as fh:
11+
with open("README.md", "r") as fh:
1212
long_description = fh.read()
1313

1414

1515
with open("testipy/requirements.txt", "r") as fr:
1616
install_requires = str(fr.read()).split("\n")
17-
print("requires:", install_requires)
17+
print("requires -", install_requires)
1818

1919

2020
setuptools.setup(

testipy/readme.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
2+
# 1. Installation
3+
- ## From GitHub
4+
- Clone this repo:
5+
```bash
6+
git clone https://github.com/pjn2work/TestiPy.git
7+
```
8+
- Change any setting you'd like inside this file [default_config.py](https://github.com/pjn2work/TestiPy/blob/main/testipy/configs/default_config.py) \(this step is optional\)
9+
- Install:
10+
```bash
11+
# Windows
12+
install.bat
13+
```
14+
```bash
15+
# Linux or Mac
16+
./install.sh
17+
```
18+
- ## From PyPi
19+
```bash
20+
pip install testipy
21+
```
22+
23+
24+
# 2. Running TestiPy
25+
- ## if you didn't install it, just cloned
26+
```bash
27+
# goto your folder where you've cloned this repo
28+
cd /where_you_have_cloned_this_repo
29+
30+
# run demo tests indicating where the tests are and using the web reporter
31+
python testipy/run.py -tf testipy/tests -r web
32+
```
33+
- ## if you install
34+
```bash
35+
# run demo tests indicating where the tests are and using the web reporter
36+
testipy -tf /where_you_have_cloned_this_repo/testipy/tests -r web
37+
```
38+
39+
40+
# 2.1. Test selection options:
41+
Select Tests (by tags coded in suites and tests with @TAG, @NAME, @LEVEL, @FEATURES)
42+
#### options (excludes have higher importance over includes):
43+
-ip Include Package (ex: -is qa.regression -es qa.regression.dev), can be several
44+
-ep Exclude Package
45+
-is Include Suite (ex: -is suiteCertificates -is MICROSERVICES -es DEV), can be several
46+
-es Exclude Suite
47+
-it Include Test (ex: -it REST), can be several
48+
-et Exclude Test
49+
-sb filename of the StoryBoard to run (ex: -sb storyboard_QA_rest.json -sb "/qa/tests/sb/sb01.json"), can be several
50+
-ilv Include tests of level y (ex: -ilv 5 -ilv 8)
51+
-elv Exclude tests of level y
52+
-alv Include tests above level y (ex: -alv 5)
53+
-blv Include tests below level y
54+
-if Include tests by @FEATURES tag (ex: -if 850222)
55+
-ef Exclude tests by @FEATURES tag
56+
-itn Include tests by @TN tag (beginsWith) (ex: -itn 1.3.1.10)
57+
-etn Exclude tests by @TN tag (beginsWith)
58+
59+
60+
# 2.2. Select Reporters
61+
- ### options:
62+
* **-reporter** or **-r** add Reporter (ex: -reporter echo -reporter log -reporter web)
63+
64+
* **echo:** shows test execution on stdout, and errors in stderr
65+
* **excel:** creates an Excel file with test execution summary and test execution details
66+
* **log:** shows test execution on .log file, with the same name as the project_name, errors are shown in stderr
67+
* **portalio:** ReportPortalIO Web REST DB and reporter:
68+
* **slack:** tests results are sent to Slack channel
69+
* **web:** tests results can be seen in realtime on a browser
70+
* **xml:** test results will be saved on report.xml file
71+
72+
73+
# 2.3. Run:
74+
- ### options:
75+
* **-rid** RunID (ex: -rid 17, if not passed than current hour and minute will be used ex: 2359)
76+
* **-pn** ProjectName (ex: -pn jules)
77+
* **-env** EnvironmentName to test (ex: -env dev)
78+
* **-rf** ResultsFolder (ex: -rf "/qa/test_results/"), where the tests results will be stored
79+
* **-tf** TestsFolder (ex: -tf "/qa/tests_scripts/jules/"), full path to where the tests are
80+
* **-repeat** Run the exact same pipeline that amount of times (ex: -repeat 3)
81+
* **-st** Suite Threads = 1..8 (ex: -st 4, meaning 4 suites can run in parallel)
82+
83+
- ### flags
84+
* **--dryrun** All tests will run but without really being executed (all of them will end with SKIPPED)
85+
* **--debugcode** Disables the try/except on tests so errors are shown
86+
* **--debug-testipy** will show the stacktrace for testipy classes
87+
* **--1** Override test definitions of how many times tests will run (ncycle)
88+
* **--prof** Create file .prof with profiling data
89+
90+
91+
# 3. Example of usage:
92+
- #### Example of usage:
93+
```
94+
python3 run.py -env dev -reporter log -reporter web -rid 1 -tf "/home/testipy/my_test_scripts" -et NO_RUN -it DEV
95+
```
96+
- #### Storyboard:
97+
- If storyboard passed, tests will run by the order defined on json file
98+
- If no storyboard is passed, then tests will run ordered (DESC) by package name, @PRIO defined on suite, then by @PRIO defined on test itself
99+
- #### Results Folder:
100+
- A folder will be created under the (specified -rf option) composed by: projectName_currentDate_RID (ex: testipy_20201231_00525)
101+
- Under the folder defined above, subfolders can be created with package_name/suite_name containing the tests results (created by each reporter)
102+
- #### Tests not ended:
103+
- If a test ends without being formally ended (by a testFailed, testSkipped or testPassed), it will be passed by the executor
104+
105+
106+
# 4. Suite Example
107+
``` python
108+
from typing import Dict
109+
110+
from testipy.helpers.handle_assertions import ExpectedError
111+
from testipy.reporter import ReportManager
112+
113+
from pet_store_toolbox import Toolbox
114+
115+
116+
_new_pet = {
117+
"id": 1,
118+
"name": "Sissi",
119+
"category": {
120+
"id": 1,
121+
"name": "Dogs"
122+
},
123+
"photoUrls": [""],
124+
"tags": [
125+
{
126+
"id": 0,
127+
"name": "Schnauzer"
128+
},
129+
{
130+
"id": 0,
131+
"name": "mini"
132+
}
133+
],
134+
"status": "available"
135+
}
136+
137+
138+
class SuitePetStore:
139+
"""
140+
@LEVEL 1
141+
@TAG PETSTORE
142+
@PRIO 2
143+
"""
144+
145+
def __init__(self):
146+
self.toolbox = Toolbox()
147+
148+
# Create a new pet
149+
def test_create_pet_valid(self, ma: Dict, rm: ReportManager, ncycles=1, param=None):
150+
"""
151+
@LEVEL 3
152+
@PRIO 5
153+
"""
154+
current_test = rm.startTest(ma)
155+
156+
data = {
157+
"control": {"expected_status_code": 200},
158+
"param": _new_pet,
159+
"expected_response": _new_pet
160+
}
161+
162+
try:
163+
self.toolbox.post_pet(rm, current_test, data, "create_pet")
164+
except Exception as ex:
165+
rm.testFailed(current_test, reason_of_state=str(ex), exc_value=ex)
166+
else:
167+
rm.testPassed(current_test, reason_of_state="pet created")
168+
169+
# Get the pet created before
170+
def test_get_pet_valid(self, ma: Dict, rm: ReportManager, ncycles=1, param=None):
171+
"""
172+
@LEVEL 3
173+
@PRIO 10
174+
@ON_SUCCESS 5
175+
"""
176+
current_test = rm.startTest(ma)
177+
178+
data = {
179+
"control": {"expected_status_code": 200},
180+
"param": _new_pet["id"],
181+
"expected_response": _new_pet
182+
}
183+
184+
try:
185+
self.toolbox.get_pet(rm, current_test, data, "get_pet")
186+
except Exception as ex:
187+
rm.testFailed(current_test, reason_of_state=str(ex), exc_value=ex)
188+
else:
189+
rm.testPassed(current_test, reason_of_state="pet fetched")
190+
```

0 commit comments

Comments
 (0)