Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Ambiente de Testes em Python

Projeto de estudo de testes com:

  • FastAPI (API)
  • Pytest (testes)
  • pytest-mock (mock)
  • SQLAlchemy + SQLite em memória (teste de banco)
  • pytest-cov (coverage)
  • GitHub Actions (CI/CD)

Estrurura do Projeto:

ambiente-teste/
├─ app/
│ ├─ __init__.py
│ ├─ main.py
│ ├─ services.py
│ └─ db.py
│
├─ tests/
│ ├─ __init__.py
│ ├─ test_services.py
│ ├─ test_api.py
│ └─ test_db.py
│
├─ .github/
│   └─ workflows/
│       └─ tests.yml
│
├─ .gitignore
├─ requirements.txt
├─ pyproject.toml
├─ README.md
└─ venv/

Requisitos

  • Python 3.11 ou superior
  • Git (opcional, para versionamento)

Como Rodar Localmente

Windows (PowerShell):

Crie e ative o ambiente virtual:

python -m venv venv
.\venv\Scripts\Activate.ps1

Linux / macOS (Terminal):

Crie e ative o ambiente virtual:

python3 -m venv venv
source venv/bin/activate

Instalar Dependências:

Com o ambiente virtual ativo:

pip install -r requirements.txt

Executar Testes

Rodar todos os testes:

pytest

Rodar testes com relatório de cobertura:

pytest --cov=app --cov-report=term-missing

Listar testes sem executar:

pytest --collect-only

Executar a API

Para subir o servidor localmente:

uvicorn app.main:app --reload

Acesse no navegador:


Integração Contínua (CI/CD)

O projeto utiliza GitHub Actions para executar automaticamente:

  • Instalação de dependências
  • Execução de testes
  • Análise de cobertura

A cada push ou pull request, o workflow é acionado.

Arquivo de configuração:

.github/workflows/tests.yml

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages