From 77a22d06c4f8ccfb71e336b3f41689fd4f69010f Mon Sep 17 00:00:00 2001
From: Thiago Nogueira dos Santos
Date: Mon, 12 Feb 2024 18:08:28 -0300
Subject: [PATCH] =?UTF-8?q?Refatora=C3=A7=C3=A3o=20no=20projeto?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.github/workflows/continuous-testing.yml | 49 +++++++++++-------------
README.md | 14 +++----
resources/base.resource | 11 +-----
resources/helpers.resource | 4 +-
resources/services.resource | 39 +++++++++++++------
resources/variables.resource | 4 ++
tests/accounts.robot | 7 +---
tests/balance.robot | 2 +-
tests/movement.robot | 2 +-
9 files changed, 66 insertions(+), 66 deletions(-)
create mode 100644 resources/variables.resource
diff --git a/.github/workflows/continuous-testing.yml b/.github/workflows/continuous-testing.yml
index fc4a4ad..c1b50b2 100644
--- a/.github/workflows/continuous-testing.yml
+++ b/.github/workflows/continuous-testing.yml
@@ -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
@@ -44,9 +39,9 @@ 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
@@ -54,7 +49,7 @@ jobs:
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
\ No newline at end of file
diff --git a/README.md b/README.md
index 3c35480..3d8832f 100644
--- a/README.md
+++ b/README.md
@@ -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)
@@ -7,9 +7,9 @@
-## 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 🚀 🚀
@@ -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 relatórios da execução.
-
-Abra o arquivo `report.html` ou `log.html` que é mais detalhado.
+Verifique a pasta `reports` para visualizar os relatórios da execução: `report.html` ou `log.html`.
---
-Thiago Nogueira dos Santos 🤓 🫰🏽
+Thiago Nogueira dos Santos 🤓 ✌🏻
QA Automation Engineer 🔎 🐞
\ No newline at end of file
diff --git a/resources/base.resource b/resources/base.resource
index c90ef28..3141bee 100644
--- a/resources/base.resource
+++ b/resources/base.resource
@@ -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=thinogueiras@testing.com
- ... senha=test123
+ IF $TOKEN == '${EMPTY}'
${response} POST
... url=${BASE_URL}/signin
diff --git a/resources/helpers.resource b/resources/helpers.resource
index 802e36c..af45389 100644
--- a/resources/helpers.resource
+++ b/resources/helpers.resource
@@ -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}
@@ -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
diff --git a/resources/services.resource b/resources/services.resource
index 5ff4db5..d21c231 100644
--- a/resources/services.resource
+++ b/resources/services.resource
@@ -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 ***
@@ -12,8 +13,8 @@ Get Account
... alias=Barriga-REST
... url=/contas
... expected_status=any
-
- [Return] ${response}
+
+ RETURN ${response}
Edit Account
[Arguments] ${account_name} ${payload}
@@ -25,8 +26,8 @@ Edit Account
... url=/contas/${account_id}
... json=${payload}
... expected_status=any
-
- [Return] ${response}
+
+ RETURN ${response}
Insert Account
[Arguments] ${payload}
@@ -36,8 +37,8 @@ Insert Account
... url=/contas
... json=${payload}
... expected_status=any
-
- [Return] ${response}
+
+ RETURN ${response}
Delete Account
[Arguments] ${account_id}
@@ -47,7 +48,7 @@ Delete Account
... url=/contas/${account_id}
... expected_status=any
- [Return] ${response}
+ RETURN ${response}
Get Account Balance
[Arguments] ${account_name}
@@ -61,7 +62,7 @@ Get Account Balance
${value} Find Value By Id ${response.json()} ${account_id}
- [Return] ${value}
+ RETURN ${value}
Get All Movements
${response} GET On Session
@@ -69,7 +70,7 @@ Get All Movements
... url=/transacoes
... expected_status=any
- [Return] ${response}
+ RETURN ${response}
Insert Movement
[Arguments] ${payload}
@@ -80,7 +81,7 @@ Insert Movement
... json=${payload}
... expected_status=any
- [Return] ${response}
+ RETURN ${response}
Delete Movement
[Arguments] ${movement_id}
@@ -90,4 +91,18 @@ Delete Movement
... url=/transacoes/${movement_id}
... expected_status=any
- [Return] ${response}
\ No newline at end of file
+ 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
\ No newline at end of file
diff --git a/resources/variables.resource b/resources/variables.resource
new file mode 100644
index 0000000..22f45b9
--- /dev/null
+++ b/resources/variables.resource
@@ -0,0 +1,4 @@
+*** Variables ***
+${BASE_URL} https://barrigarest.wcaquino.me
+&{AUTH} email=thinogueiras@testing.com senha=test123
+${TOKEN} ${EMPTY}
\ No newline at end of file
diff --git a/tests/accounts.robot b/tests/accounts.robot
index 510d326..8601871 100644
--- a/tests/accounts.robot
+++ b/tests/accounts.robot
@@ -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
\ No newline at end of file
+ Check Route Authentication contas saldo transacoes movimentacoes
diff --git a/tests/balance.robot b/tests/balance.robot
index 01aa3ac..7239435 100644
--- a/tests/balance.robot
+++ b/tests/balance.robot
@@ -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
diff --git a/tests/movement.robot b/tests/movement.robot
index 22a15d7..51a99e8 100644
--- a/tests/movement.robot
+++ b/tests/movement.robot
@@ -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