This project contains automated tests for the AutomationExercise API using Python and the requests library. The tests are designed to verify various API endpoints and ensure they behave as expected.
In addition to automated tests, manual testing of the API endpoints has been performed using Postman. The Postman collection and environment files are included in the Manual_Postman directory. These files can be imported into Postman to manually test the API endpoints.
The project includes automated tests for the following API endpoints:
-
POST /api/verifyLogin: Verifies login with valid and invalid details.- Valid Login: Tests the login functionality with valid email and password.
- Invalid Login: Tests the login functionality with missing or incorrect email/password.
-
DELETE /api/verifyLogin: Verifies that the DELETE method is not allowed on the login endpoint.- Method Not Allowed: Ensures that a DELETE request to the login endpoint returns a 405 status code.
-
POST /api/productsList: Retrieves the list of products.- Get All Products: Tests the retrieval of all products using a POST request.
-
POST /api/searchProduct: Searches for a product by name.- Search Product: Tests the search functionality by providing a product name.
-
POST /api/createAccount: Creates a new user account.- Create Account: Tests the account creation functionality with valid user details.
-
POST /api/deleteAccount: Deletes an existing user account.- Delete Account: Tests the account deletion functionality with valid user credentials.
-
Clone the repository:
git clone https://github.com/yourusername/automationexercise-api-testing.git cd automationexercise-api-testing -
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the required dependencies:
pip install -r requirements.txt
To run the tests, you need to have the pytest framework installed. You can run the tests using the following command:
pytestThe tests are located in the Automation_Pytest directory. Each test file contains tests for specific API endpoints.
To run a specific test file, use the following command:
pytest Automation_Pytest/test_POST_Operations.pyYou can also generate a detailed report by using the -v (verbose) option:
pytest -vIn addition to automated tests, manual testing of the API endpoints has been performed using Postman. The Postman collection and environment files are included in the Manual_Postman directory. These files can be imported into Postman to manually test the API endpoints.
- Open Postman.
- Click on the
Importbutton in the top-left corner. - Select the
Manual_Postmandirectory and choose the collection file (*.postman_collection.json). - Click on
Importto add the collection to your Postman workspace.
- Select the imported collection from the left sidebar.
- Choose the desired request from the collection.
- Ensure the correct environment is selected from the environment dropdown in the top-right corner.
- Click on the
Sendbutton to execute the request and view the response.
Contributions are welcome! If you would like to contribute to this project, please follow these steps:
-
Fork the Repository: Click on the
Forkbutton at the top right of this page to create a copy of this repository in your GitHub account. -
Clone the Repository: Clone the forked repository to your local machine using the following command:
git clone https://github.com/razvanalexuc/automationexercise-api-testing.git cd automationexercise-api-testing -
Create a New Branch: Create a new branch for your feature or bugfix:
git checkout -b feature-or-bugfix-name
-
Make Changes: Make your changes to the codebase.
-
Commit Changes: Commit your changes with a descriptive commit message:
git add . git commit -m "Description of the feature or bugfix"
-
Push Changes: Push your changes to your forked repository:
git push origin feature-or-bugfix-name
-
Create a Pull Request: Go to the original repository on GitHub and create a pull request from your forked repository. Provide a clear description of your changes and why they should be merged.