TheSwarm 1.1.7
The Swarm project is now deprecated. Focus has been shifted to a multi-language version of the project - https://github.com/The-Erebus-Project
dotnet add package TheSwarm --version 1.1.7
NuGet\Install-Package TheSwarm -Version 1.1.7
<PackageReference Include="TheSwarm" Version="1.1.7" />
<PackageVersion Include="TheSwarm" Version="1.1.7" />
<PackageReference Include="TheSwarm" />
paket add TheSwarm --version 1.1.7
#r "nuget: TheSwarm, 1.1.7"
#:package TheSwarm@1.1.7
#addin nuget:?package=TheSwarm&version=1.1.7
#tool nuget:?package=TheSwarm&version=1.1.7
The Swarm
The Swarm is a light-weight, flexible and scalable performance testing tool. Write your test scenarios and define user behavior using plain C# code, store task sets/sequences/scenarios and re-use them, execute the tests any way you like - whether integrated into existing testing solutions or executed on it's own.
Downloads
The latest releases are available on NuGet or GitHub.
Getting started
To prepare our first scenario we need to prepare several components:
- Task set, which will define user's behavior
- Executor sequence - the scenario itself. This will define the test flow itself - how much users to use at any given moment, how long to run it for, etc
Task sets are created by marking the type with SwarmTaskSet annotation. Task set type usually consists of following:
- The client, decorated with RegisterSwarmClient attribute - this points the client to results listener and makes sure the results are reported.
- The task methods themselves, decorated with SwarmTask attribute
- Optionally, task set can have pre/after test methods (SwarmTaskSetSetup and SwarmTaskSetTeardown) and pre/after task methods (SwarmBeforeTask and SwarmAfterTask) - former are executed once in the beginning and end of the test, and the latter are executed before and after each task.
using TheSwarm;
using TheSwarm.Clients;
using TheSwarm.Attributes;
[SwarmTaskSet(TaskSetID = "TC-1", Description = "Test taskset")]
public class TestClass
{
// Client needs to be registered to make sure it will report the results to results listener
[RegisterSwarmClient]
SwarmHttpClient client { get; } = new SwarmHttpClient();
// Methods marked as SwarmTaskSetSetup will be executed once before the task loop begins
[SwarmTaskSetSetup]
public void Setup()
{
client.BaseURL = "https://google.com/";
}
// Tasks can have weight (more weight - higher chance to be executed) and set delay after the execution in milliseconds
[SwarmTask(Weight = 15, DelayAfterExecution = 50)]
public void OpenIndex()
{
client.Get(name: "Open Index", "/");
}
[SwarmTask(Weight = 5, DelayAfterExecution = 50)]
public void SearchSwarm()
{
client.Get(name: "Search \"Swarm\"", uri:"/search?q=swarm");
}
}
Once task set is defined, we can create the scenario itself:
SwarmPreparedTestScenario scenario = TheSwarm.SwarmBuilder
.InitializeScenario()
.InitializeResultsListener(mode: SwarmListenerMode.Local, printStats: true) // Initialize local results listener and enable current stats printing in console
.InitializeLoopedTaskExecutor() // Initialize looped task executor
.SetExecutorTaskSet("TC-1") // Use the task set TC-1 we've created earlier
.SetExecutorSequence((executor) => // Define the executor sequence - the scenario itself
executor
.CreateUsers(5) // Create 5 users at once and start execution
.WaitSeconds(10) // Keep them working for 10 seconds
)
.Build();
scenario.RunScenario(); // Start execution
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.