Skip to content

Commit

Permalink
API SH (#21)
Browse files Browse the repository at this point in the history
### To be filled by the PR creator:

* A brief description of the changes made - 

* Do we have clean latest run report attached with this PR?
  * [ ] Yes
  * [ ] No (Please explain why)

* Does the PR contain changes to any BP core file?
  * [ ] Yes (Needs approval from at least 2 people)
  * [ ] No

* Does the PR contain changes to modules shared with other teams?
* [ ] Yes (Needs approval from at least one of the other teams that use
the module)
  * [ ] No

* Is it
  * [ ] New Testcase
  * [ ] Fix


### To be filled by the PR reviewer:

* [ ] Verify the attached run report passed in GitHub Actions (Justify
if local run)

* General
    * [ ] Use the best strategy to locate the elements
    * [ ] Comments wherever the code is not readable by itself
    * [ ] Use of the right data structure for the use case
    * [ ] Reuse logic/functionality as much as possible
    * [ ] Cleanup of any test data that is generated by the tests
    * [ ] No static waits
  • Loading branch information
Tauqir Sarwar authored Mar 17, 2024
2 parents 6dd6c1f + 64e1bf0 commit abb390d
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 18 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/api_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,31 @@ jobs:
fi
source $HOME/.bp-venv/bin/activate
python -m pytest -v \
--reruns 1 --reruns-delay 2 \
--gherkin-terminal-reporter \
--tags=""$TAGS"" \
--html=report.html \
sh api_run.sh "$TAGS"
- name: Get Allure history
uses: actions/checkout@v4
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- name: Allure Report
uses: simple-elf/[email protected]
if: always()
with:
gh_pages: gh-pages
allure_results: allure-results
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
with:
PERSONAL_TOKEN: ${{ secrets.PYTEST_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history

# Upload html results as GH artifact
- name: Upload pytest test results
Expand Down Expand Up @@ -95,12 +115,7 @@ jobs:
fi
source $HOME/.bp-venv/bin/activate
python -m pytest -v \
--reruns 1 --reruns-delay 2 \
--gherkin-terminal-reporter \
--tags="$TAGS" \
--html=report.html \
--alluredir=allure-results
sh api_run.sh "$TAGS"
- name: Get Allure history
uses: actions/checkout@v4
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,19 +395,31 @@ The right approach is:
When I click on 'login > sign-in'
And The element 'login > email' is displayed
And I set text 'username' to field 'login > email'
<p align="right">(<a href="#about-the-project">back to top</a>)</p>
Always use these common points:
+ Write clear & concise features using Gherkin, to define behaviour of the system.
Scenario Structure
+ Organize scenarios into meaningful groups.
+ Use scenarios to describe test cases / user stories, keeping them focused & atomic
Reusable Steps
+ Identify common steps that can be reused across multiple scenarios & abstract them into reusable step definitions.
Test Data Management
+ Manage test data effectively.
+ Ensure each scenario has necessary data inputs to execute successfully.
Notifications
---------------------
**Slack and MS Teams notifications support is available, we can set webhooks in pytest.ini file**
# Slack Notification arguments
--slack-webhook-url=https://hooks.slack.com/services/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
--slack-webhook-url=https://hooks.slack.com/services/....
--slack-channel=pytest-test-automation
--slack-results-url=http://localhost:63342/pytest-automation-boilerplate/output/allure/reports/index.html
# Teams Notification arguments
--teams-webhook-url=https://moduscreate.webhook.office.com/webhookb2/efb47054-dc3a-42c9-9546-0589ac5d1ce2@d3552869-ed01-465b-8f62-e394dea60dc9/IncomingWebhook/d86b6fd3e9e446c49d4549a25a981703/58f5c251-1381-455a-bdbf-54c859982512
--teams-webhook-url=https://moduscreate.webhook.office.com/...
--teams-results-url=http://localhost:63342/pytest-automation-boilerplate/output/allure/reports/index.html
Expand Down
4 changes: 4 additions & 0 deletions api_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Run API tests
python -m pytest -v -s --gherkin-terminal-reporter --html="./output/reports/" --tags=$1 --self-contained-html --reruns 1 --reruns-delay 2 --alluredir=allure-results
2 changes: 1 addition & 1 deletion bp_core/frontend/common/utils/locator_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _parse_locator_string(
locator_string: str, default_loc_type=ValidLocatorTypes.XP
) -> Locator:
if (
match := re.match("^\[(XP|TN|ID|CS|CN|NM|LT|PL)\](.+)$", locator_string)
match := re.match("^[(XP|TN|ID|CS|CN|NM|LT|PL)](.+)$", locator_string)
) is not None:
type_ = getattr(ValidLocatorTypes, match.groups()[0])
identifier = match.groups()[1]
Expand Down
4 changes: 2 additions & 2 deletions bp_core/utils/dataset_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def __init__(
self.dataset = dataset

def parse_and_get(self, string_to_format: str):
match = re.findall("\{(.*?)\}", str(string_to_format))
match = re.findall("{(.*?)}", str(string_to_format))
if len(match) > 0:
if self.dataset._dataset_prefix == '':
raise DatasetHandlerException(
"Please provide the environment of the files using '--dataset-prefix [value]' within CLI arguments")
file_name = string_to_format[1:string_to_format.index(":") + 1]
string_to_format = string_to_format.replace(file_name, '')
file_name = re.findall('[0-9a-zA-Z_-]+', file_name)
match = re.findall("\{(.*?)\}", str(string_to_format))
match = re.findall("{(.*?)}", str(string_to_format))
keys = deque(match[0].split("~"))
data = self.dataset[f"{self.dataset._dataset_prefix}{file_name[0]}"]
value = data.get(keys.popleft().strip())
Expand Down

0 comments on commit abb390d

Please sign in to comment.