This document will help you learn about NBomber.HTTP plugin in more detail.
NBomber.Http provides a simple API to define HTTP steps, calculate response size, apply assertions.
Add HTTP package into your project.
Create HTTP load test
NBomber.Http provides HTTP API that can be used to create/send request and check response. It supports HTTP protocol specific concepts like HEADERS, BODY, VERSION.
NBomber.Http provides a convenient way to define HTTP request and then send it.
By default, NBomber.Http sets HTTP Version 1.1 but you can override this.
By default, NBomber.Http sets no headers but you can override this.
By default, NBomber.Http is using this check for every response but you can override it.
HttpClientFactory abstraction that can be used to init a base HttpClient that will be used within your test.
NBomberHttpClientFactory creates only one instance of HttpClient and uses it for all steps. You can override it if you need it.
By default, NBomber.Http uses HttpClient with default timeout for 100 seconds. A Domain Name System (DNS) query may take up to 15 seconds to return or time out. You can adjust and set a cutom timeout.
Also, pay attention that NBomber Step has a default timeout for 1 second.
There may be situations when you need to trace your requests and responses. The NBomber.Http has built-in functionality for tracing every request/response. In order to start tracing you need to set minimum logging level to Verbose.
Also, you can enable tracing via the infrastructure config file.
To work with the JSON format, you can use any library you prefer. Here is a list of popular libraries:
Here is an example with using
Newtonsoft.Json, but you can use any other.
- To test HTTP use LoadSimulation.InjectPerSec since usually web server is an open system. You can read more here.
- For debugging or tracing you can use LoadSimulation.KeepConstant with copies = 1 since for this simulation NBomber will use a single thread which is easier to debug.
- Use Ping plugin to get more info about networking.
- Convert your integration tests to load tests