Skip to main content


The NBomber.Data package provides functionality for NBomber to work with data.


To start working with NBomber.Data package you should install it:

dotnet add package NBomber.Data

Also, the source code is available on Github.

Generate random bytes

Generates an array with random bytes. This method is helpful when you want to test some system (over TCP/etc.) and for this, you need to send a message with a concrete size (for example, 4KB).

public static byte[] GenerateRandomBytes(int sizeInBytes)


var data = Data.GenerateRandomBytes(100);

Generate fake data

NBomber doesn’t provide tools to generate fake test data. To generate fake data for your tests, we highly recommend looking at Bogus fake data generator.

Data Feed

Data Feed helps inject test data into your load test. It represents a data source (In-Memory, JSON, CSV).

Load data

// It's a type that represents user-defined data.
public class User
public int Id { get; set; }
public string Name { get; set; }

// Load by file path. All data will be fully loaded into memory.
var csvData = Data.LoadCsv<User>("users-feed-data.csv");
var jsonData = Data.LoadJson<User[]>("users-feed-data.json");

// Load by HTTP
var csvData = Data.LoadCsv<User>("");
var jsonData = Data.LoadJson<User[]>("");

You can find the complete example by this link.

Inject data

After loading the data, we will need to inject it into Scenario.

var feed = DataFeed.Circular(data);
//var feed = DataFeed.Constant(data);
//var feed = DataFeed.Random(data);

var scenario = Scenario.Create("scenario", async context =>
var item = feed.GetNextItem(context.ScenarioInfo);

context.Logger.Information("Data from feed: {0}", item.Name);

await Task.Delay(1_000);
return Response.Ok();

NBomber provides multiple strategies for the built-in data feeders.

// Creates DataFeed that goes back to the top of the sequence once the end is reached.
var feed = DataFeed.Circular(data);

// Creates DataFeed that picks constant value per Scenario copy.
// Every Scenario copy will have unique constant value.
var feed = DataFeed.Constant(data);

// Creates DataFeed that randomly picks an item per GetNextItem() invocation.
var feed = DataFeed.Random(data);