https://github.com/zoxive/httploadtesting
Load testing client + framework
https://github.com/zoxive/httploadtesting
http load-testing
Last synced: 7 months ago
JSON representation
Load testing client + framework
- Host: GitHub
- URL: https://github.com/zoxive/httploadtesting
- Owner: Zoxive
- License: mit
- Created: 2016-09-29T18:43:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-02-15T10:57:41.000Z (almost 3 years ago)
- Last Synced: 2025-07-22T09:50:11.923Z (7 months ago)
- Topics: http, load-testing
- Language: C#
- Homepage:
- Size: 262 KB
- Stars: 6
- Watchers: 1
- Forks: 4
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HttpLoadTesting
HTTP Load testing when single HTTP endpoint is not enough.
Allows you to write test scenarios.
Install via nuget
```Install-Package Zoxive.HttpLoadTesting.Client```
```csharp
// Test
public class ReadAPost : ILoadTest
{
public string Name => "ReadAPost";
public Task Initialize(ILoadTestHttpClient loadTestHttpClient)
{
// nothing to initialize
return Task.FromResult(0);
}
public async Task Execute(ILoadTestHttpClient loadTestHttpClient)
{
// Simulate user delay in clicking (User think time)
await loadTestHttpClient.DelayUserClick();
// User had to open the post
await loadTestHttpClient.Get("posts/1");
// User thinking and typing
await loadTestHttpClient.DelayUserThink()
var comment = new Dictionary
{
{"name", "HttpLoadTesting"},
{"email", "vel+minus+molestias+voluptatum@omnis.com"},
{"body", "Comment body"}
};
await loadTestHttpClient.Post("posts/1/comments", comment);
}
}
// Console Application
public class Program
{
public static void Main(string[] args)
{
// Specify schedules. Add a few users run for a while and remove them. You can run any schedule in any order.
// As long as you have active users!
var schedule = new List
{
// Add Users over a period of time
new AddUsers(totalUsers: 10, usersEvery: 2, seconds: 5),
// Run for a duration of time
new Duration(0.25m),
// Remove Users over a period of time
new RemoveUsers(usersToRemove: 10, usersEvery:2, seconds: 1)
};
// Create as many tests as you want to run
// These are the tests each User will run round robin style
var tests = new List
{
new ReadAPost()
};
// Create one or more "HttpUsers".
// This is essentually the HTTP Connection each simulated user will use. Round robin style
var users = new List
{
new HttpUser("https://jsonplaceholder.typicode.com/", tests)
{
// Specify any properties i need on HttpClient. Like header values!
AlterHttpClient = SetHttpClientProperties,
// Specify any properties i need on HttpClientHandler. Like Cookies!
AlterHttpClientHandler = SetHttpClientHandlerProperties
}
};
var testExecution = new LoadTestExecution(users);
// Run the Tests!
WebClient.Run(testExecution, schedule);
}
}
```