A simple api testing repo demonstrating the ease of api testing using python, uplink
- Easy to understand code
- Github CI integration
- Dockerised
- Install python
- Install pip
- Install Docker
- Install Docker Compose
- Install any IDE of your choice
- Install project dependencies
# to create a new virtual environment for the project pipenv shell # installing requirements from the pipenv install -r ./requirements/requirements.txt requirements.txt file # to activate the shell pipenv activate
- To set up the auto formatting prior to code commit run the code once during set up
pipenv run pre-commit install
- Build the project image using below command
docker build -t python_test/simple-api-test:latest -f Dockerfile .
- Invoke the allure-docker-service
docker compose up -d -or- docker compose up -d --build
- When trying to run, the below tests using allure-service you might encounter permission denied error, to resolve that:
sudo chmod 777 allure-reports sudo chmod 777 allure-results
- If you are thinking where the report would be getting stored, it will be stored in the allure-reports directory with in the project root
- To run the test, use the below commands
# parallel mode pytest -n <number_of_parallel_threads> <relative_.py_test_file_path> -or- # normal mode pytest <relative_.py_test_file_path> -or- pytest <relative_.py_test_file_path>::<specific_method_that_required to be run> # want to generate report along with it pytest <relative_.py_test_file_path>::<specific_method_that_required to be run> --alluredir=allure-results -or- pytest <relative_.py_test_file_path> --alluredir=allure-results -or- pytest -n <number_of_parallel_threads> <relative_.py_test_file_path> --alluredir=allure-results -or- pytest -n <number_of_parallel_threads> --alluredir=allure-results