https://github.com/imrostami/requester
Simple and powerful library for Testing API Endpoints
https://github.com/imrostami/requester
api-testing httpc request-lib requests test webapi
Last synced: 8 months ago
JSON representation
Simple and powerful library for Testing API Endpoints
- Host: GitHub
- URL: https://github.com/imrostami/requester
- Owner: imrostami
- License: gpl-3.0
- Created: 2024-09-01T19:42:46.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-09-02T11:44:12.000Z (over 1 year ago)
- Last Synced: 2025-07-22T06:21:42.072Z (9 months ago)
- Topics: api-testing, httpc, request-lib, requests, test, webapi
- Language: C#
- Homepage:
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Requester
A simple and efficient tool for testing your API endpoints without any hassle. Just create and add your request endpoints, then run the tests.

## Let's get started
First, we create a class that inherits from the base class `RequestEndpoint`
For example:
```cs
[Endpoint("/todos")]
internal class JsonPlaseholderTest : RequestEndpoint
{
public override async Task Handle(IEndpointResult previousResult)
{
var todos = await GetAsync();
if (todos.IsSuccessStatusCode)
return TestSucceeded(todos);
return TestFailed(todos);
}
}
```
Each `RequestEndpoint` provides two functions for sending the final response: `TestSucceeded` and `TestFailed`. You send the response generated in the current test as input to these functions so that it remains available for subsequent tests. For example, if you want to retrieve a todo item by its ID, which was created from the response of the previous test, you can access it using the `previousResult` object from parameter
It also has functions to send requests to specified endpoints such as
`GetAsync`
`PostAsync`
and..
is
But note that entering the functions does not require entering the request address
Finally, to set up the request pipeline, you need to add your tests in your console application with `MapFromAssembly` and execute the `RunTests` function
```cs
var baseAddress = new Uri("https://jsonplaceholder.typicode.com");
var builder = new RequesterBuilder(baseAddress)
.MapFromAssembly(typeof(Program).Assembly);
var app = builder.Build();
await app.RunTests();
```