Skip to content

Commit

Permalink
Refatoração no projeto
Browse files Browse the repository at this point in the history
  • Loading branch information
thinogueiras committed Feb 18, 2024
1 parent 9a27ffb commit 77a22d0
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 66 deletions.
49 changes: 22 additions & 27 deletions .github/workflows/continuous-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,28 @@ on:

jobs:
api-tests:
runs-on: ubuntu-22.04
name: Run Robot Framework API Tests 🤖
runs-on: ubuntu-latest
name: Robot Framework API Tests 🤖🤖

steps:
- name: Checkout 🚀
uses: actions/checkout@v3

- name: Install Robot Framework
run: |
pip install robotframework
- name: Install Python Requests Library
run: |
pip install robotframework-requests
- name: API Tests ✅
run: |
robot -d ./logs tests/
- name: Upload Reports 📖
- name: Checkout 🚀🚀
uses: actions/checkout@v4

- name: Install dependencies ➕➕
run: pip install -r requirements.txt

- name: API Tests 🧪🧪
run: robot -d ./reports tests/

- name: Upload Reports 📖📖
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Execution Test Reports
path: logs/
name: Test Execution Reports
path: reports
retention-days: 90
if-no-files-found: warn

- name: Slack Notification - Success
if: ${{ success() }}
uses: rtCamp/action-slack-notify@v2
Expand All @@ -44,17 +39,17 @@ jobs:
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://cdn-icons-png.flaticon.com/512/1642/1642322.png
SLACK_TITLE: 'All tests passed successfully'
SLACK_MESSAGE: ':robot: Tests after Pull Request passed :robot:'
SLACK_MESSAGE: ':robot: Tests passed :robot:'
SLACK_USERNAME: SUCCESS

- name: Slack Notification - Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: pipeline-notifications
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://www.novaconcursos.com.br/portal/wp-content/uploads/2013/12/erro-que-concurseiro-comente-300x3001.png
SLACK_ICON: https://cdn-icons-png.flaticon.com/512/3271/3271351.png
SLACK_TITLE: 'Some tests failed'
SLACK_MESSAGE: ':fire: Tests after Pull Request failed :fire:'
SLACK_MESSAGE: ':fire: Tests failed :fire:'
SLACK_USERNAME: FAILURE
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Automação de Testes de API com Robot Framework e Python Requests Library.
# Automação de Testes de API REST com Robot Framework e Python Requests Library.

[![Robot Framework - API Tests](https://github.com/thinogueiras/Robot-API-Tests/actions/workflows/continuous-testing.yml/badge.svg)](https://github.com/thinogueiras/Robot-API-Tests/actions/workflows/continuous-testing.yml)

Expand All @@ -7,9 +7,9 @@
<img src=".github/images/python.png" width="325px">
</p>

## Pré-requisitos de ambiente 📋 💻
## Pré-requisitos mínimos de ambiente 📋 💻

[Python](https://www.python.org/downloads/) 3.10.12 ou superior.
* [Python](https://www.python.org/downloads/) 3.10.12 ou superior.

## Instalação do projeto 🚀 🚀

Expand All @@ -20,19 +20,17 @@ pip install -r requirements.txt
## Execução dos testes 🤖 🤖

```
robot -d ./logs tests/
robot -d ./reports tests/
``````

## Relatórios 📝 📄

Verifique a pasta `logs` para visualizar os <b>relatórios</b> da execução.

Abra o arquivo `report.html` ou `log.html` que é mais detalhado.
Verifique a pasta `reports` para visualizar os <b>relatórios</b> da execução: `report.html` ou `log.html`.

---

<a href="https://www.linkedin.com/in/thinogueiras"><img alt="Linkedin" src="https://img.shields.io/badge/-LinkedIn-blue?style=for-the-badge&logo=Linkedin&logoColor=white"></a>

<strong>Thiago Nogueira dos Santos</strong> 🤓 🫰🏽
<strong>Thiago Nogueira dos Santos</strong> 🤓 ✌🏻

QA Automation Engineer 🔎 🐞
11 changes: 2 additions & 9 deletions resources/base.resource
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ Documentation Arquivo base do projeto
Library libs/search_values.py

Resource services.resource

*** Variables ***
${BASE_URL} https://barrigarest.wcaquino.me
${TOKEN}
Resource variables.resource

*** Keywords ***
Setup
IF $TOKEN == '${null}' or $TOKEN == '${EMPTY}'

${AUTH} Create Dictionary
... [email protected]
... senha=test123
IF $TOKEN == '${EMPTY}'

${response} POST
... url=${BASE_URL}/signin
Expand Down
4 changes: 2 additions & 2 deletions resources/helpers.resource
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Get Account ID By Name
... url=/contas?nome=${account_name}
... expected_status=any

[Return] ${response.json()}[0][id]
RETURN ${response.json()}[0][id]

Get Movement ID By Name
[Arguments] ${movement_description}
Expand All @@ -22,7 +22,7 @@ Get Movement ID By Name
... url=/transacoes?descricao=${movement_description}
... expected_status=any

[Return] ${response.json()}[0][id]
RETURN ${response.json()}[0][id]

Reset Database
${response} GET On Session
Expand Down
39 changes: 27 additions & 12 deletions resources/services.resource
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
*** Settings ***
Documentation Serviços

Library libs/search_values.py
Library RequestsLibrary
Library libs/search_values.py

Resource variables.resource
Resource helpers.resource

*** Keywords ***
Expand All @@ -12,8 +13,8 @@ Get Account
... alias=Barriga-REST
... url=/contas
... expected_status=any
[Return] ${response}

RETURN ${response}

Edit Account
[Arguments] ${account_name} ${payload}
Expand All @@ -25,8 +26,8 @@ Edit Account
... url=/contas/${account_id}
... json=${payload}
... expected_status=any
[Return] ${response}

RETURN ${response}

Insert Account
[Arguments] ${payload}
Expand All @@ -36,8 +37,8 @@ Insert Account
... url=/contas
... json=${payload}
... expected_status=any
[Return] ${response}

RETURN ${response}

Delete Account
[Arguments] ${account_id}
Expand All @@ -47,7 +48,7 @@ Delete Account
... url=/contas/${account_id}
... expected_status=any

[Return] ${response}
RETURN ${response}

Get Account Balance
[Arguments] ${account_name}
Expand All @@ -61,15 +62,15 @@ Get Account Balance

${value} Find Value By Id ${response.json()} ${account_id}

[Return] ${value}
RETURN ${value}

Get All Movements
${response} GET On Session
... alias=Barriga-REST
... url=/transacoes
... expected_status=any

[Return] ${response}
RETURN ${response}

Insert Movement
[Arguments] ${payload}
Expand All @@ -80,7 +81,7 @@ Insert Movement
... json=${payload}
... expected_status=any

[Return] ${response}
RETURN ${response}

Delete Movement
[Arguments] ${movement_id}
Expand All @@ -90,4 +91,18 @@ Delete Movement
... url=/transacoes/${movement_id}
... expected_status=any

[Return] ${response}
RETURN ${response}

Check Route Authentication
[Arguments] @{routes}

FOR ${route} IN @{routes}

${response} GET
... url=${BASE_URL}/${route}
... headers=${EMPTY}
... expected_status=any

Status Should Be 401

END
4 changes: 4 additions & 0 deletions resources/variables.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*** Variables ***
${BASE_URL} https://barrigarest.wcaquino.me
&{AUTH} [email protected] senha=test123
${TOKEN} ${EMPTY}
7 changes: 1 addition & 6 deletions tests/accounts.robot
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,4 @@ Não deve remover conta com movimentação
Should Be Equal ${response.json()}[constraint] transacoes_conta_id_foreign
Deve exigir autenticação
${response} GET
... url=${BASE_URL}/contas
... headers=${EMPTY}
... expected_status=any
Status Should Be 401
Check Route Authentication contas saldo transacoes movimentacoes
2 changes: 1 addition & 1 deletion tests/balance.robot
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Deve validar o saldo da conta
${response} Get Account Balance Conta para saldo
Status Should Be 200
Should Be True ${response} == 534
2 changes: 1 addition & 1 deletion tests/movement.robot
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Deve retornar todas as Movimentações
${response} Get All Movements
${size} Get Length ${response.json()}
Status Should Be 200
Should Be True ${size} == 6
Expand Down

0 comments on commit 77a22d0

Please sign in to comment.