Welcome to Dasty, a powerful tool for API testing and benchmarking. This guide will help you get started with setting up Dasty and running your first API scenarios.
-
Install Dasty: Ensure that Dasty is installed in your environment. You can install it via pip (Python's package installer):
pip install dasty
-
Dependencies: Make sure all dependencies are installed. Dasty typically requires packages like
requests
,yaml
, andtabulate
.
To run standard API scenarios:
-
Create Your Scenario File: Write your API scenarios in a YAML file. Here's an example structure:
name: "Sample API Test" description: "A simple test scenario" steps: - name: "Get Request" method: "GET" url: "http://example.com/api" expected_status_code: 200
-
Run the Scenario: Use the
ScenarioRunner
to execute your scenarios.from dasty import ScenarioRunner runner = ScenarioRunner(directory="path/to/your/scenarios") runner.run()
Dasty's benchmarking feature allows you to measure the performance of your API scenarios:
-
Switch to Benchmarker: Instead of using
ScenarioRunner
, useBenchmarker
.from dasty import Benchmarker benchmarker = Benchmarker(directory="path/to/your/scenarios") benchmarker.run()
-
View Benchmark Results: After running the scenarios, you will see an output like this:
Add, Get, and Delete Users -------------------------- METHOD URL TIME (ms) REQUEST SIZE (bytes) RESPONSE SIZE (bytes) -------- ---------------------------------------- ----------- ---------------------- ----------------------- GET http://127.0.0.1:2396/ 2.09 0 2 GET http://127.0.0.1:2396/users 1.45 0 84 ... (additional rows of data) ...
This output includes the method, URL, time taken, request size, and response size for each API call in your scenario.
- Organize Your Scenarios: Keep your scenarios organized in specific directories for easy management.
- Understand the Metrics: Familiarize yourself with the different metrics provided by the benchmarking feature, such as response times and payload sizes.
- Test Under Realistic Conditions: For the most accurate benchmarking results, test under conditions that closely mimic your production environment.