Trafix is a modern, efficient API testing framework that simplifies the process of generating, executing, and managing API test cases. Built with a Go backend and Next.js frontend, Trafix delivers high performance, reliability, and an intuitive user experience.
- Dynamic Test Case Generation: Automatically create test cases based on provided API details.
- Interactive Frontend: A clean and responsive interface for managing test cases and viewing results.
- Test Case Customization: Edit, delete, or add new test cases seamlessly.
- Execution and Results Display: Execute test cases and review structured results, including status codes, response bodies, and execution times.
- Frontend Workflow
- Backend Workflow
- Backend Test Case Generation
- Usage
- License
- Future-Enhancements
- Contributing
-
API Information Form:
- Input fields for:
- Endpoint URL
- HTTP Method (GET, POST, PUT, DELETE)
- Headers (optional)
- Payload/Body (for POST/PUT requests)
- Input fields for:
-
Generated Test Cases Display:
- View autogenerated test cases, such as boundary tests and response validation tests.
-
Edit Test Cases:
- Modify, delete, or add new test cases.
-
Execute Test Cases:
- Click a button to execute all test cases.
-
View Results:
- Results displayed in a table format with:
- Test case name
- Status code
- Response body
- Execution time
- Results displayed in a table format with:
- Receiving API Info: API details are received from the frontend via the Go backend.
- Generating Test Cases:
- Predefined logic or AI APIs (e.g., OpenAI) create diverse test cases.
- Test cases are stored in a MongoDB database.
- Execution Trigger: A Kestra workflow is initiated with test case details.
- Execution and Storage:
- Test cases are executed, and results are stored in MongoDB.
- Results include response details like status codes and execution times.
- Manual Execution: Test cases can be executed manually via the backend API.
- Endpoint:
/api/test-cases/run
- Input: Test case details
- Uses Go routines for parallel execution.
- Endpoint:
- Customization: Users can customize test cases or add new ones as needed.
-
Receive API Info:
- Endpoint:
/api/generate-test-cases
- Input: API details (URL, method, headers, payload)
- Validation: Ensure required fields are provided.
- Endpoint:
-
Generate Test Cases:
- Happy Path Tests: Valid inputs expected to succeed.
- Negative Tests: Invalid inputs (e.g., wrong data types, missing fields).
- Boundary Tests: Edge cases for parameters.
- Performance Tests: High payload or frequent requests.
-
Store Test Cases:
- Save test cases in the
test_cases
collection in MongoDB.
- Save test cases in the
-
Execute Test Cases:
- Endpoint:
/api/test-cases/run
- Trigger Kestra workflows for test execution.
- Endpoint:
-
View Results:
- Display test results with details like status codes and execution times.
- Data stored in the
test_results
collection in MongoDB can be viewed in the frontend.
After setting up the backend and frontend, you can start using Trafix to test APIs. Follow these steps to get started with the development environment:
-
Clone the Repository:
git clone https://github.com/kyrexis/trafix.git
-
Add environment variables:
- Create a
.env
file in thefrontend
andbackend
directory, following theenv.example
file.
- Create a
-
Install Dependencies:
-
Install dependencies for the frontend and backend:
cd frontend npm install cd ../backend go mod tidy
-
-
Run the Application:
-
Start the frontend and backend servers:
cd frontend npm run dev cd ../backend air
-
The frontend will be available at
http://localhost:3000
, and the backend will run onhttp://localhost:5000
. -
Install Air using
go install github.com/air-verse/air@latest
if you don't have it installed. -
Start redis server using
redis-server
if you don't have it running or use Docker.docker run -dp 6379:6379 redis
-
Trafix is licensed under the MIT License.
We have exciting plans to further improve Trafix and provide a more comprehensive API testing experience:
- Enhanced Reporting: Add more detailed analytics and insights for test case execution, such as visualized metrics and trends.
- Multiple Test Formats: Provide support for importing and exporting test cases in popular formats like Postman collections and Swagger files.
- Integration Testing: Extend the framework to include support for integration testing, enabling end-to-end validations.
- CI/CD Integration: Seamlessly integrate Trafix with CI/CD pipelines using tools like Jenkins, GitHub Actions, GitLab CI, and others.
Trafix is Open Source 🥳🥳
Feel free to reach out to us if you have any questions or ideas. We welcome contributions to Trafix! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request to the
main
branch.
Please make sure your code follows the existing style and includes proper tests where applicable.
We encourage contributions from the community. Whether it's fixing a bug, adding a new feature, or improving documentation, your input is valuable. For any questions or feedback, feel free to open an issue or reach out to us.