Walkthrough to install, set up and run the tests.
Scenarios for the APIs ReqRes and JSON Place Holder
Install latest Python
Note: Check
Add Python 3.8 to PATH
option during the installation
Install latest GIT to clone the repository
Download the latest report framework Allure and unzip in any folder (e.g. /Downloads)
- Open the Powershell terminal:
Start Menu > type it 'Powershell'
- Set Allure Framework
PATH
with the command:
$env:PATH += ';\Allure_Folder_Path\allure-x.xx.x\bin'
Install latest Java JDK and open the options: Start Menu > type it 'Environment' > 'Edit Environment Variables' > Environment Variables
- Create a new user variable
JAVA_HOME
and set has value the path where Java was installed - Create a new system variable in Path, adding the expression
%JAVA_HOME%\bin
- Restart PC.
Install latest Python (executable): sudo apt-get install python3
Install Python pip: sudo apt install python3-pip
Install GIT: sudo apt install git
Download the latest report framework Allure and unzip in any folder.
Open bash terminal and set the Allure Framework folder path bin
in PATH
environment:
export PATH=$PATH:~/Allure_Path/bin
source ~/.bashrc
Install latest Java JDK and create environment variable JAVA_HOME
and set has value the path where Java was installed.
Set the folder \bin
in Path environment.
Note: Guide to install Java in Linux guia da Oracle
After that it should be possible to check the Allure version (allure --version
) to confirm if PATH
was set correctly.
Create a folder that will receive the repository files.
Clone the repo Behave Framework and access the cloned folder.
Install the package pipenv
: pip install pipenv
Run the VirtualEnv using command: pipenv shell
Install the dependencies from Pipfile
(root directory): pipenv install
Wait for the all dependencies be installed.
To run all tests use the commands below.
The parameters are:
-f allure_behave.formatter:AllureFormatter
: output format (Allure Framework)
-o allure_result_folder
: folder where the output will be saved
./features
: features that will be executed
behave features\employees\employee_management.feature -f allure_behave.formatter:AllureFormatter -o allure_result_folder
After test conclusion, use the command below to generate the Allure report.
This command will create a local server that will read the files from allure_result_folder
and will launch the results on browser:
allure serve allure_result_folder
API tests reports are available on browser.
GitHub: Behave Framework
- Behave - BDD with Python
- Allure-Behave - Framework for reports
- Faker - Faker data generator
- Pipenv - Package/VirtualEnv manager
- Requests - HTTP library
- PyHamcrest - Framework for matcher objects